H
hector santos
Guest
I have some PHP classes that I am porting to C#. I almost got it except for the final two classes. I have be comment with "// ?? HOW TO DO.." and the compiler ERROR . How to do get two interfaces and two instances of the interfaces and a two classes that inherent a "handling" classes. How it makes sense of this. Thanks
public class CDoor
{
interface iWildcatConsoleIO
{
string GetDeviceType();
bool Initialize();
bool ShutDown();
}
class CWildcatDeviceDoor32 : iWildcatConsoleIO
{
public string GetDeviceType() { return "WCDOOR32"; }
public bool Initialize() { return wcDoor32API.DoorInitialize(); }
public bool ShutDown() { return wcDoor32API.DoorShutdown(); }
}
class CWildcatDeviceCRT32 : iWildcatConsoleIO
{
public string GetDeviceType() { return "WCCRT32"; }
public bool Initialize() { return true; }
public bool ShutDown() { return true; }
}
// ?? I don't want this class to be public
public class CWildcatConsole : wcServerAPI
{
private bool Active = false;
private iWildcatConsoleIO _interface = null;
private string interfaceType = "";
CWildcatConsole(iWildcatConsoleIO _interface = null)
{
if (this._interface == null)
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") != "")
{
_interface = new CWildcatDeviceDoor32();
this.interfaceType = "WCDOOR32";
}
else
{
_interface = new CWildcatDeviceCRT32();
this.interfaceType = "WCCRT32";
}
}
this._interface = _interface;
if (this._interface.Initialize())
{
this.Active = true;
return; // true;
}
return; // false;
}
~CWildcatConsole()
{
if (this.Active)
{
this._interface.ShutDown();
}
}
//---------------
// Public
//---------------
public string GetDeviceType()
{
return this._interface.GetDeviceType();
}
} // end of CWildcatConsole
//------------------------------------------------------------
// Use this class for pure DOO32 operations
//------------------------------------------------------------
public class CWildcatDoor : CWildcatConsole
{
// ?? HOW TO DO THIS
CWildcatDoor()
// Error CS0122 'CDoor.CWildcatConsole.CWildcatConsole(CDoor.iWildcatConsoleIO)'
// is inaccessible due to its protection level
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") == "")
{
Console.WriteLine("This class is used for WCDOOR32 mode.");
Environment.Exit(1); // die;
return;
}
// ?? HOW TO DO THI IN C#, __construct is PHP class constructor
return parent::__construct(new CWildcatDeviceDoor32());
// Error CS0432 Alias 'parent' not found
}
}
//------------------------------------------------------------
// Use this class for pure CRT32 local mode operations
//------------------------------------------------------------
public class CWildcatLocal : CWildcatConsole
{
// ?? HOW TO DO THIS
CWildcatLocal()
// Error CS0122 'CDoor.CWildcatConsole.CWildcatConsole(CDoor.iWildcatConsoleIO)'
// is inaccessible due to its protection level
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") != "")
{
Console.WriteLine("This class is used for WCCRT32 mode.");
Environment.Exit(1); // die;
}
// ?? HOW TO DO THIS IN C#, __construct is PHP class constructor
return parent::__construct(new CWildcatDeviceCRT32());
// Error CS0432 Alias 'parent' not found
}
}
}
Hector Santos, CTO Santronics Software, Inc. Santronics Software, Inc.
Continue reading...
public class CDoor
{
interface iWildcatConsoleIO
{
string GetDeviceType();
bool Initialize();
bool ShutDown();
}
class CWildcatDeviceDoor32 : iWildcatConsoleIO
{
public string GetDeviceType() { return "WCDOOR32"; }
public bool Initialize() { return wcDoor32API.DoorInitialize(); }
public bool ShutDown() { return wcDoor32API.DoorShutdown(); }
}
class CWildcatDeviceCRT32 : iWildcatConsoleIO
{
public string GetDeviceType() { return "WCCRT32"; }
public bool Initialize() { return true; }
public bool ShutDown() { return true; }
}
// ?? I don't want this class to be public
public class CWildcatConsole : wcServerAPI
{
private bool Active = false;
private iWildcatConsoleIO _interface = null;
private string interfaceType = "";
CWildcatConsole(iWildcatConsoleIO _interface = null)
{
if (this._interface == null)
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") != "")
{
_interface = new CWildcatDeviceDoor32();
this.interfaceType = "WCDOOR32";
}
else
{
_interface = new CWildcatDeviceCRT32();
this.interfaceType = "WCCRT32";
}
}
this._interface = _interface;
if (this._interface.Initialize())
{
this.Active = true;
return; // true;
}
return; // false;
}
~CWildcatConsole()
{
if (this.Active)
{
this._interface.ShutDown();
}
}
//---------------
// Public
//---------------
public string GetDeviceType()
{
return this._interface.GetDeviceType();
}
} // end of CWildcatConsole
//------------------------------------------------------------
// Use this class for pure DOO32 operations
//------------------------------------------------------------
public class CWildcatDoor : CWildcatConsole
{
// ?? HOW TO DO THIS
CWildcatDoor()
// Error CS0122 'CDoor.CWildcatConsole.CWildcatConsole(CDoor.iWildcatConsoleIO)'
// is inaccessible due to its protection level
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") == "")
{
Console.WriteLine("This class is used for WCDOOR32 mode.");
Environment.Exit(1); // die;
return;
}
// ?? HOW TO DO THI IN C#, __construct is PHP class constructor
return parent::__construct(new CWildcatDeviceDoor32());
// Error CS0432 Alias 'parent' not found
}
}
//------------------------------------------------------------
// Use this class for pure CRT32 local mode operations
//------------------------------------------------------------
public class CWildcatLocal : CWildcatConsole
{
// ?? HOW TO DO THIS
CWildcatLocal()
// Error CS0122 'CDoor.CWildcatConsole.CWildcatConsole(CDoor.iWildcatConsoleIO)'
// is inaccessible due to its protection level
{
if (Environment.GetEnvironmentVariable("wcdoorpipename") != "")
{
Console.WriteLine("This class is used for WCCRT32 mode.");
Environment.Exit(1); // die;
}
// ?? HOW TO DO THIS IN C#, __construct is PHP class constructor
return parent::__construct(new CWildcatDeviceCRT32());
// Error CS0432 Alias 'parent' not found
}
}
}
Hector Santos, CTO Santronics Software, Inc. Santronics Software, Inc.
Continue reading...