Overview
The previous article introduced a very simple and basic application of MEF, implemented the MEF framework and demonstrated some of the basic requirements and settings of the MEF framework, which are important, and then we analyze how to extend or enhance the MEF framework content.
Enhanced Contract Class Library
In fact, with the introduction of the previous article, readers will soon find that the Contract class library is very restrictive, or "it" Only refers to the common class library of the system.xxx type that comes with Windows, and often in the protocol we refer to the methods and members in our actual project engineering, which leads to the reliance on a non-system public class library, such as PRACTISE_MEF. Core. Can that still be achieved, my plugin just generates a "Class library DLL"?
First, let's look at the dependency plot:
All project projects here will depend on the core, where PRACTISE_MEF and practise_mef.contract are direct references (Copy Local = True), PRACTISE_MEF. Plugin.multicalculateex is an indirect reference (Copy Local = False), here Calculateex the project does not reference the core, and if the reference is an indirect reference. The extension library will not produce or copy Core.DLL after an indirect reference, but rather rely on the host (generally referred to as the UI class library that calls the Extension class library, here is PRACTISE_MEF), so that the plug-in class library will only produce its own class library DLL without producing a referenced DLL, at least it looks neat.
Project Refactoring
With these technical mats, we provide a bright path to refactoring software for the MEF architecture. However, the road is always tortuous.
First of all, since the framework is based on protocol, it is important to analyze what public properties and methods are in the project to be refactored to extract the interfaces, which is of paramount importance, if there is no commonality, the meaning of refactoring itself is not very large.
In the process of collating and extracting the core class library of the project, I think a few aspects deserve to be put forward in the core:
- BaseForm
- Foundation of the Module/entity/objects
- Interface interface
- Enum enum
- Commissioned delegate
- Tool Class Utility
- Basic Method Fucntion
。。。
Other, business logic, non-basic methods are extracted to the BLL and other upper modules.
Docker framework
Under WinForm recommended Weifenluo DockPanel plug-in, this plug-in is easy to implement, powerful, you can add the plugin form as a subset of Docker, layout similar to the Visual Studio Editor.
Introduction Weifenluo:
Http://www.cnblogs.com/wuhuacong/archive/2009/07/09/1520082.html
Summarize
With the accumulation of the above three aspects, it is possible to refactor into a MEF plugin framework.
Because this project is still in the open, so the relevant code should not be disclosed.
Refactoring Notes---MEF framework (bottom)