Hi All,
I'm not sure this is the correct location on the forum however here goes!
I have been given a task to encapsulate functions which are taken from a toolkit into a DLL to be used in other programs.
My first stumbling block is I'm not sure how I can do this, the tookit requires you to create a class which is then used throughout the rest of the application however I'm not sure how I can create my own class which returns this to then be used in other classes?
I've tried searching but can't find anything which gives me some guidance on how to do this. Any help would be appreciated.
An example of the code is as follows:
string nodeName = Environment.MachineName;
string galaxyName = "Example1";
// create GRAccessAppClass object
GRAccessApp grAccess = new GRAccessAppClass();
// try to get galaxy
IGalaxies gals = grAccess.QueryGalaxies(nodeName);
if (gals == null || grAccess.CommandResult.Successful == false)
{
Console.WriteLine(grAccess.CommandResult.CustomMessage + grAccess.CommandResult.Text);
return;
}
IGalaxy galaxy = gals[galaxyName];
ICommandResult cmd;
// create galaxy if it doesn't already exist
if( galaxy == null )
{
grAccess.CreateGalaxy(
galaxyName,
nodeName,
false, // no security
EAuthenticationMode.galaxyAuthenticationMode,
"" );
cmd = grAccess.CommandResult;
if (!cmd.Successful)
{
Console.WriteLine("Create Galaxy Named Example1 Failed: " +
cmd.Text + " : " +
cmd.CustomMessage);
return;
}
galaxy = grAccess.QueryGalaxies( nodeName )[ galaxyName ];
}
I'd want to return galaxy to then use in other classes.
Loading
Sam HobbsPosted Mar 7, 2011, 8:16 PM
Note that when you say "encapsulate" I think you are describing something that is often called a wrapper. If everything will be managed code, both the toolkit wrapper and the user of the toolkit, then the I think what you need to do is to use a class library for the wrapper. Look for articles in this web site about class libraries and relevant MSDN articles and documentation and articles and books elsewhere too abot class libraries. A class library is essentially a special kind of DLL that is developed using and that is for use by managed code.
Pete OConnellPosted Mar 8, 2011, 4:07 AM
Mahesh ChandPosted Mar 7, 2011, 8:54 PM