The development of MONGODB management tools Mongocola has entered its third year.
The official lack of input to C # has led to a lot of things that have to be done on their own, but in any case, the tools are powerful now.
Recently ready to start the development of plug-in systems, simple plug-in system, in fact, the amount of code is very small.
1. Plug-in base class
The plug-in system requires the support of a plug-in base class, which sets the intrinsic fields that a plug-in contains, such as plug-in name, plug-in description, plugin author, and so on.
At the same time, also defines the main method name, after all, the plug-in system must use reflection to complete, so many things must be unified.
Using System; Namespace Magicmongodbtool.common {Public abstract class Plugbase {///<summary>///path class [
Considering that possible hierarchies will change later]///</summary> public enum Pathlv:int {///<summary>
Connection/server///</summary> connectionlv = 0,///<summary> Specific examples///</summary> Instancelv = 1,///<summary>///
Database///</summary> Databaselv = 2,///<summary>///Data set
</summary> COLLECTIONLV = 3,///<summary>///data document </summary> DOCUMENTLV = 4,///<summary>///Miscellaneous///<
/summary> Misc = 9}///<summary>///plug-in menu representation name///</summary> public string plugname = String.Empty;
<summary>///Plug-in features brief///</summary> public string plugfunction = String.Empty;
<summary>///Processing Object///</summary> public dynamic plugobj;
<summary>///Object Level///</summary> public pathlv runlv = PATHLV.CONNECTIONLV; <summary>///Run///</summary>///<returns></returns> PU
Blic abstract int Run (); }
}
Run is an abstract method, and since it is an abstract method, the plug-in that inherits the class must implement this method. Run is also the entry function for the tool to invoke the plug-in function later.
This base class, can be in the form of source code to add to the project inside the plug-in, of course, can also be made into a DLL, let the plug-in project reference. I now say it's made of a DLL.