First, the preface
Plug-in model refers to the application by a number of dynamic independent modules, each module has one or more services, and to meet a certain plug-in protocol, can use the main program to achieve the main program-Plug-ins, Plug-ins-plug-ins between the communication. It defines a common set of interfaces that communicate with Plug-ins through an interface, primarily through reflection to obtain related properties and methods, before performing the specified operation. In fact, it can also be understood to define a common set of solutions, through reflection, to get the relevant types of assemblies, and then to perform the related operations of these specified types. It is a Plug and Play scheme, easy to update and maintain.
This article is just a description of the General plug-in development model, the design is relatively simple, the main steps are as follows:
(1), defining common interfaces, and abstract classes.
(2), define and implement related components.
(3) Implement common assembly reflection Operation class.
Where the common interfaces and abstract classes are defined in the component Jasen.Framework.Core, the component provides a generic assembly reflection operation class Assemblyutility, and the relevant components for implementation are Jasen.Framework.Oracle, Jasen.Framework.Access and Jasen.Framework.SqlServer, they all implement the common interface in Jasen.Framework.Core. The client can perform the appropriate operation according to the actual situation. The related component diagram is as follows:
Definition of common interface and abstract class and definition and implementation of related components
First, define common interfaces and abstract classes, as shown in the following class diagram, defining a common interface idatatable, defining an abstract class DataTable, which is placed in the topmost assembly. The other components are recreated separately, implementing the corresponding functions, such as sqlserverdatatable, oracledatatable, and accessdatatable to implement their respective functions. Note: When Assembly.loadfile (file) dynamically loads an assembly, the assembly must not exist in the current running environment, or unexpected data exceptions may occur, so the implementation of the related component must be independent (just implement the public interface).