Pete OConnell

Pete OConnell

  • NA
  • 3
  • 4.7k

How can I encapsulate a toolkit into a DLL?

Mar 7 2011 5:16 PM
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.

Answers (3)