Setup
Setup for DotExtension's manager is really a series of calls to Setup:

DotExtension.Manager.Instance.Setup(typeof(MyObject).Assembly);


The code above takes the assembly that MyObject is within and searches for any and all extensions, instantiates them, and then saves them in the global list. You can also specify a directory if the assembly containing the extensions is not loaded.

Creating an Extensions
Creating an extension is very simple. The DotExtension project has a base class called Extension. Inheriting from this class ensures that DotExtension can find the extension during the call to setup. It also contains a property Configuration of type ExtensionConfig. This is where an individual extension stores any data that it needs in order to run. As an example, let's look at a sample extension:

    public class ExtensionExample:DotExtension.BaseClasses.Extension
    {
        public ExtensionExample()
            : base()
        {
            SomeObject.EventIWantToTieInto+=new EventHandler<EventArgs>(MyFunction);
        }

        public void MyFunction(object sender,EventArgs e)
        {
        }
    }


With the code above we really have two points of interest. When the object is instantiated, it ties into an event (EventIWantToTieInto). So every time that event is called, the function MyFunction is called. Thus the extension ties itself into the system where it needs to be. The only part left is setting up the config class for the extension itself:

    [ConfigAttribute(Name = "ExtensionExample")]
    public class ExtensionConfig:DotExtension.Config.ExtensionConfig
    {
    }


The config class above doesn't specify anything (and as such nothing is being saved/loaded). However the ConfigAttribute's Name property denotes that it is to be used with the ExtensionExample extension and is automatically loaded for us in the constructor. If we wanted to we could actually specify information to be stored, but for information on that see the usage documentation for Gestalt.Net as it uses it for configuration. Anyway, with this basic knowledge you should be able to create extensions and using them within your app.

Last edited Jun 22, 2010 at 8:54 PM by JaCraig, version 1

Comments

No comments yet.