Http://mef.codeplex.com/wikipage? Title = overview & referringtitle = home)
What is MEF?
Managed extensibility framework (MEF) can easily construct scalable applications.Program. MEF provides discovery and combination capabilities, so you can choose to load the plug-in.
What problems does MEF solve?
- MEF presents a simple extension problem during runtime. Until now, if you want to support the plug-in mode for any program, you need to build your own architecture. These plug-ins are often specific applications and cannot be reused by multiple implementations.
- MEF provides a standard way for programs to expose themselves and consume external extensions. It is a natural extension that can be reused by different programs. However, an extension must implement a specific application. Extensions can depend on another extension, and MEF ensures that they are assembled at the same time in the correct order.
- MEF allows additional metadata to mark extensions in queries and filtering.
How does MEF work?
- Roughly speaking, the MEF core consists of a catalog (directory) and a compositioncontainer. A catalog is responsible for searching for extensions, and the container is responsible for coordinating creation and matching dependencies.
- The first class of MEF is composablepart. A composable part provides one or more exports, or depends on one or more extensions provided by imports. A composable part can also be an object or a given type of instance. MEF, however, is an extensible, additional composablepart implementation that is attached to the import/export contract.
- Both exports and imports have a contract ). Contract is a bridge between exports and imports. An export contract is composed of metadata used for filtering. For example, it can specify the capabilities provided by an export.
- MEF containers interact with catalogs to access composable parts. The container solves some dependencies and exposes exports to the outside world. You can add composable part instances as needed.
- A composablepart returns a catalog, which is very similar to an extension in your program. It has Imports Provided by the Host Program, and then export other.
- By default, MEF composable part uses attribute metadata to declare exports and imports. This allows MEF to determine which parts, imports, and exports are completely available.