Programmer's Guide (Supporting ADX v03.1.00) Manual

Brocade Virtual ADX XML API Programmer’s Guide 839
53-1003248-01
Example - Provisioning real and virtual servers
B
//
// Parameters: addr - the ip address which needs to be validated.
//
// Return Value: Success if true.
/////////////////////////////////////////////////////////////////////////////
public bool IsValidIP(string addr)
{
System.Net.IPAddress ipAddress = null;
bool isValidIp = System.Net.IPAddress.TryParse(addr, out ipAddress);
return isValidIp;
}
/////////////////////////////////////////////////////////////////////////////
// Name: OpenRCloseLog
//
// Description: This function will be called to open or close the log file.
//
// Parameters: bOpen - true/false
//
/////////////////////////////////////////////////////////////////////////////
public bool OpenRCloseLog(bool bOpen)
{
string sLogPath = "";
//get the full location of the assembly with DaoTests in it
string sfullPath =
System.Reflection.Assembly.GetAssembly(typeof(Utils)).Location;
//get the folder that's in
string sDirectory = Path.GetDirectoryName(sfullPath);
sLogPath = String.Format("{0}\\ConfigureSLB.txt", sDirectory);
//check whether m_StreamWriter object is null before opening the log
file
if (bOpen == true && m_StreamWriter == null)
{
m_FileStream = new FileStream(sLogPath, FileMode.OpenOrCreate |
FileMode.Append, FileAccess.Write);
m_StreamWriter = new StreamWriter(m_FileStream);
if (m_StreamWriter == null)
{
return false;
}
return true;
}
else
{
//Check the validity of the streamwriter before calling close
command
if (m_StreamWriter != null)
{
//Close the log file
m_StreamWriter.Close();
m_FileStream.Close();
m_FileStream = null;
m_StreamWriter = null;
}
}
return true;
}