Refer to <C#插件构架实战>
1. A common interface IPlugIn will be provided. For the host application, it will use this interface to provide necessary information to the plug-in components. For the plug-in component, it will implement this interface to let the host operate on it.
2. A common interface of host application will be provided also. The plug-in component should be able to get this interface through IPlugIn, so that it can operate on the host application.
3. When the application run, it will load the plug-in component files. Using the reflection technic, it will create the plug-in instance and get the interface IPlugIn. Then the host provides the interface of itself to the plug-in instance through IPlugIn. Then the plug-in instance can operate on the host now
Host load the plugin component files. |
Host use reflection technic to create the plug-in instance, get the IPlugIn. |
Host transfer its own interface through IPlugIn to the plug-in instance. |
plug-in instance operate on the host through the interface it gets |