Implementation of the Winform development framework-Implementation of the hybrid framework-evolution of the Winform development framework-introduction to the implementation of the offline WCF development framework

Source: Internet
Author: User
Document directory
  • 3. Implementation of a hybrid framework
  • 4. Composition of project files

In my previous article "evolution of the Winform Development Framework framework", I introduced the traditional Winform development framework, the traditional WCF development framework, the offline WCF development framework, and the hybrid WCF development framework, the first two are familiar frameworks, followed by the offline WCF development framework, I also elaborated on the offline-style WCF development framework in the introduction to implementation of Winform development, it can be viewed as a traditional Winform development framework + WCF synchronization module. This article continues to explore the framework design and implementation in this regard, focusing on the design ideas and Implementation of the hybrid WCF development framework.

The hybrid framework of Winform development framework can be seen as a dual framework that can be freely switched between the traditional winform development framework and the WCF development framework. This framework is characterized, it refers to dividing the system into many omnipotent modules (both WInform integration and WCF integration) and performing different switching on different occasions, in addition, you only need to configure parameter changes to achieve the jump, which is very conducive to the Integration encapsulation of modules.

1. Features of hybrid frameworks

Hybrid frameworks have the following features:

1) strong environmental adaptability and high reusability of modules. Because the hybrid framework can be used for both traditional Winform System Development and WCF distributed system development, it is highly adaptable to the environment. In addition, the modules have these features and are more reusable, especially for general modules, it has irreplaceable advantages.

2) Better response performance. If it is a Winform program, you can directly access the database. If it is a WCF call method, you can use the dedicated channel of WCF for data processing to better utilize system resources and efficiently process data.

3) Independent configuration with less code modifications. All common modules configure the WCF connection through independent configuration files to reduce the complexity of the master configuration file. the WCF Service Logic independent class library can adopt multiple service boarding methods.

2. Overall Design Concept of hybrid frameworks

The Hybrid Framework of the Winform development framework is still based on the modular concept. It can be divided into two major modules: the main business system modules (such as the spare parts management system ), one module is a variety of auxiliary modules (such as general permission, general dictionary, general attachment management, general personnel management ....), These two combinations are a perfect system.

As you can see, the business system modules and auxiliary modules of the entire system are based on an idea. Through the interface call switch, the WCF Service layer is called, or Winform business layer (direct access to the database). Of course, the call at the interface layer is based on the same interface, whether calling the WCF Service layer or Winform service layer. We can call it the Facade layer. Auxiliary modules are a combination of multiple common modules. They may be the following common modules: general permission module, general dictionary module, general attachment management module, and general personnel management module.

 

3. Implementation of a hybrid framework

To better understand the Winform development framework, I will introduce the implementation of this hybrid framework through the general dictionary module, one of the auxiliary modules. The internal structure of the dictionary module is as follows.

 

As follows:

1) shared class libraries and entity classes run through the entire framework.

2) Databases use generic inheritance to implement less code and richer API implementations.

3) multi-database support. By using the EnterpriseLibrary enterprise class library, it supports the integration of multiple databases.

4) built-in Winform and WCF call implementation. The configuration file facilitates free switching.

5) The UI Layer calls the Facade-based interface (rather than the specific implementation class) through the factory class of the interface call layer ).

6) share the UI Layer. The UI Layer is consistent with that of Winform and WCF, with only one UI Layer.

7) each layer has a base class with less code and more support.

8) each independent module constructs the entire framework ecosystem.

4. Composition of project files

The dictionary module of the entire hybrid framework is designed according to the above architecture, there will be a lot of project projects, because of the limited number of people's target recognition management, so for a single module, it is not advisable to generate too many project DLL; otherwise, integration will be difficult and not suitable for better maintenance. Therefore, based on the principle of minimal DLL, I designed the following Module Directory. Basically, each directory represents a layer.

Since the above framework also integrates the call Method Based on the WCF method, you also need to create a WCF dictionary service. In order to enable WCF to support more boarding methods, you can create a WCF Service library project, as shown below.

After the corresponding layers and logic classes are created, the specific project is as follows (some files are used in multiple projects, So copying is avoided by reference and can be centrally managed, such as the interface file of the Facade layer ).

Of course, there will also be a way to host the WCF Service, which is released through IIS here. If necessary, you can also deploy the WCF Service in other ways. Because the logic is isolated, the deployment is very convenient.

The following figure shows the WCF Service Project for IIS deployment.

For IIS deployment, there are basically two lines of code in the svc file (note that this SVC file does not have the background. cs file)

Of course, there is another way, you only need to configure Web. Config, without adding the svc file, you can also implement the deployment of the WCF Service.

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">      <serviceActivations>        <add service="WHC.Dictionary.WCFLibrary.DictTypeService" relativeAddress="test.svc"/>      </serviceActivations>    </serviceHostingEnvironment>

The above is my deduction process for the hybrid development framework. The entire framework is almost complete now, including the general permission management system module, general dictionary module, and general attachment management module, general Personnel Management Module and other general Peripheral modules. Therefore, the design of the framework has been verified in practice. Such a hybrid framework is very suitable for projects with high reusability, compared with other types of frameworks, it features higher value-added and higher availability.

I hope that through my introduction to the mixed framework design ideas and implementation logic, I will be able to further communicate and analyze with you.

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.