1 Attachment(s)
Add Plugin facility to your app
Do you want to provide Plug-in facility for your applications? This example shows a basic framework that will allow you or others to extend the functionality of your applications without having to change the base code.
In the attachment there are three project files.
1. PlugInInterface.
2. FindURLPlugIn.
3. ExtendableApp
ExtendableApp is a basic Windows Form with a menu and a TextBox. The FindURLPlugIn is a DLL that will take in the contents of the TextBox and perform an action on it. In this instance the plugin will remove any text that is not part of a url.
The process:
Build the PlugInInterface
Add a reference to the PlugInInterface in ExtendableApp
Run ExtendableApp, the PlugIn Menu will be empty.
Add a reference to the PlugInInterface in FindURLPLugIn
Build FindURLPlugIn and copy the DLL to the same location as the ExtendableApp.exe
Run ExtendableApp, the plugin should now be available from the menu.
The most important function is the FindPlugins in the ExtendableApp it searches for and loads and DLLs that implement the PlugIn Interface.
The attached file contains two copies of this example:
PlugInSample_SD
PlugInSample_VS
I use SharpDevelop hence the _SD it has a facility to export SharpDevelop combines to Visual Studio solutions, but I don’t know how well it works.
This work came about after looking at other samples, some required configuration files for the plugins. I feel this kind of defeats the purpose and others which were more complicated than strictly necessary. There is room for improvement with the FindPlugIns method any feedback improvements would be appreciated.