Whether it is using COM, common DLL, or vcq9wLTKtc/WsuW8/r/release + 1qSho9Om08OzzNDysdjQ68n5w/release/rHY0Ou3 + release S8zQ8rXEzOXPtdbQoaOxvs + plugin = "http://www.cnblogs.com/guanjinke/admin/guanjinke.cnblogs.com" title = "\">. NET implements plug-in application frameworks, so I will not mention other methods.
How to use. NET to create a contract? The first Interface is the abstract class, but I use the Interface in the plug-in mode, because we provide additional plug-in functions based on the main purpose of the application, in this regard, interfaces are more flexible and easier to expand. Next, how should we conclude the contract content? This depends on your business needs. For ease of explanation, we define a plug-in contract for the most basic plug-in applications. Let's make a hypothesis that our application is a multi-document application that contains a main menu bar, a toolbar. The menu bar can be docked in the upper, lower, and left directions of the program, and a status bar. Later, if necessary, I will extend this application so that it can provide more functions for the plug-in. So for now, the function I want to implement is to allow the plug-in to add a toolbar for the main program, menu items and implement some simple functions.
An application provides services to the plug-in two ways. One is to directly declare attributes or methods in the application interface, and the other is to declare the application interface as a service container. I plan to use both methods. Explicit functions are directly declared as attributes or methods in interfaces, and applications are declared as a service container to facilitate the insertion of more service functions, improve the scalability of applications.
Below is a very simple application interface definition, which is sufficient for our assumptions.
Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. ComponentModel. Design;
Using System. Windows. Forms;
Namespace PluginFramework
{
Public interface IApplication: IServiceContainer
{
ToolStripPanel LeftToolPanel {get ;}
ToolStripPanel RightToolPanel {get ;}
ToolStripPanel TopToolPanel {get ;}
ToolStripPanel BottomToolPanel {get ;}
MenuStrip MainMenuStrip {get ;}
StatusStrip StatusBar {get ;}
}
}
Plug-in Interface Definition:
Using System;
Using System. Collections. Generic;
Using System. Text;
Namespace PluginFramework
{
Public interface IPlugin
{
IApplication Application {get; set ;}
String Name {get; set ;}
String Description {get; set ;}
Void Load ();
Void UnLoad ();
Event EventHandler <EventArgs> Loading;
}
}