This is a mirror of official site: http://jasper-net.blogspot.com/

Steps to write a plugin based application with MEF

| Monday, August 29, 2011
Steps to create a Plugin based application :

    Before we proceed lets look how the User Interface for the application that I am building looks like :

The UI contains two Panels, one to show the UI loader control, ideally will list a Button, and another container which will load the actual UI for the application. I have used normal windows based application to make you understand better.  Initially it will show you a button, and when you click on the button, it will load the actual usercontrol.
To start creating a plugin based application, we need to create a contract that lies between the Modules and the Host. The contract restricts the Plugins to be loaded on the Host.
Lets add a Class Library to the project and name it as PluginContract. We add 3 interfaces.

public interface IProcessRunner
{
    void Process();
}


The IProcess interface includes some portion of code that you need to execute when the application is getting loaded. This interface acts as a process which the plugin needs to execute whenever the object is loaded. The idea is to separate the actual process code from the User Interface.
Next we define IPlugin interface which maps the actual User Interface of the Module. The definition of the IPlugin interface looks like :

public interface IPlugin
{
    UserControl GreeterControl { get; set; }

    bool IsPluginCreated { get; set; }
    void CreatePlugin();
    UserControl GetPlugin();

}


Read more: DOT NET TRICKS
QR: steps-to-write-plugin-based-application.html

Posted via email from Jasper-net

0 comments: