C # plug-in Development simple model

Source: Internet
Author: User
Tags abstract definition reflection

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).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.