Plug Framework

What is Plug Framework?
Plug Framework is a simple plug-in framework designed to facilitate your application with the capability of extending the feature set easily by just dropping a DLL in the designated folder.

Why Plug Framework?
There are several products which provides plug-in or add-ins but almost all of them have a huge learning curve to get yourself started. While designing Plug Framework there were few guidelines I wanted to stick to which is given below.

  • Absolutely no learning curve required.
  • Make a generic Framework to adapt to any of your requirements.
  • Drop the plug DLL in the folder and your application consumes it.
  • Enable your application with a framework and API for extending the feature set.
  • Easily build developer community around your application since it’s extremely easy to develop Plugs to enhance the feature set.

So if you are looking to enhance your application with an easy to implement and easy to use plug-in model, you just found it!

How to use Plug Framework?
Before talking about how to use this Framework, let me explain the ingredients of this Framework.

PlugFramework.Host provides the following functionality using reflection

a. Static function called “loadPlugs” which returns generic list of Plugs
b. Validate Plug DLL’s found in the folder to make sure it’s of the right iPlugType
c. Provides Assembly attributes of the Plug as part of the Plug class in collection
d. “plugInstance” function to invoke methods available inside Plugs

  

PlugFramework.Api declares API using an abstract class with virtual function

public abstract class iPlugType
{
     public virtual string returnContent(string msg)
     {
         //plug can override this method for implementation
         throw new System.NotImplementedException();
     }
}


How to use PlugHost inside your application?

string pluginPath = @” C:\Projects\PlugFramework\Plugs”;
List<Plug> plugs = PlugManager.loadPlugs(pluginPath);
    foreach (Plug plug in plugs)
    {
     //Display PlugTitle
     Console.WriteLine(plug.PlugTitle);
     //Invoke a method called “returnContent” with “sukesh” as parameter
     Console.WriteLine(plug.plugInstance().returnContent("sukesh"));
    }


How to write a Plug? 

public class Class1 : iPlugTyp
{
   public override string returnContent(string msg)
   {
    return msg + ", I'm from SamplePlug2";
   }
}


What do you get from the Plug Framework download?
Complete ready to run example with the source for Plug Framework and 2 Sample Plug showing how easy it is to implement them!

 

This is version 1.0 of the Plug Framework and I have several ideas on extending the functionality without deviating from the guidelines mentioned above.
Time is a constraint and would happen sometime in near future for sure Smile

Download Source for PlugFramework
Coming on CodePlex soon...

 

Author

Sukesh Sukesh Ashok Kumar
Works @ Microsoft
More...

Chat with me!
who's online

Disclaimer

All opinions posted here are those of the author and are in no way intended to represent the opinions of his employer. All posts are provided "AS IS" with no warranties, and confers no rights. © Copyright 2010

Recent Comments

Comment RSS

Sign in