There are a huge number of special plugins for C #. One of them is described in Plugin Architecture using C # (in Project Code ). The general approach is that the host application publishes an assembly with interfaces. It lists through the folder and finds the assemblies that define the class that implements its interfaces and loads them and instantiates the classes.
In practice, you want to do more. Best if the host application defines two interfaces: IHost and IPlugIn. The IHost interface provides services that the plugin can subscribe to. IPlugIn is created using IHost.
To download a plugin, you must do more than just get the plugin. You must list all the plugins that can be downloaded. Build them each. Ask them if they can escape. Ask them to export the API to the host. Ask them to import the API from the host. Plugins should be able to ask about the existence of other plugins.
In this way, plugins can extend the application by offering more APIs.
Plugins must include events. Thus, plugins can control the process of loading and unloading plugins.
At the end of the world, you must warn the plugins that they will leave. Then take them out.
This will leave you with an application that can be written in a tiny structure and fully implemented in plugins if you want to.
As an added bonus, you should also make sure that you enable shortcuts for plugins in the plugins folder. This allows you to write an application and transfer it to someone else. They can create a plug-in in their development environment, create a shortcut for it in the application plug-ins folder and not worry about deployment after each compilation.
plinth Feb 05 '09 at 13:55 2009-02-05 13:55
source share