Plugin is a fairly flexible, modular mechanism, and Microsoft's Application Block has a plugin structure, which discusses Plugin's practice in C #. Plugin is based on unified interface, which uses the reflection mechanism to generate an object of IPLUGIN in C #. IPlugin interface is assumed, the following code snippet dynamically generated block schematic IPlugin object is achieved wherein dllName dll file name IPlugin interface class: public IPlugin LoadPlugin (string dllName) {Assembly asm = AppDomain.CurrentDomain.Load (dllName); foreach (Type Tin (IFACE IN T.GETINTERFACES ()) {ified (IPLUGIN)) {Return (IPLUGIN)) {return; }}} Return NULL;
Java also has a Reflection mechanism, which is also very simple to implement PLUGIN, which is approximately (iplugin) class.Forname (classname) .NewInstance (). C Due to the REFLECTION mechanism, DLL simulation can be used, and an export in the DLL is a full-class function and interface, which returns a pointer to the object that implements the interface.
Microsoft is related to Provider Pattern's article, which provides an instantiation method that can be parametric.