请输入您要查询的百科知识:

 

词条 Managed Extensibility Framework
释义

  1. What problems does MEF aim to solve?

  2. How does MEF work?

  3. References

  4. External links

{{Advert|date=May 2011}}{{Infobox software
| name = Managed Extensibility Framework
| logo = Managed Extensibility Framework logo.png
| screenshot =
| caption = Part of .NET Framework 4.0
| developer = Microsoft
| latest_release_version = V1 in .NET Framework 4.0
| latest_release_date = {{Start date and age|2010|4|12|}}
| latest_preview_version = V2 Preview 5
| latest_preview_date = {{start date and age|2011|12|19}}
| genre = Web application framework
| license = Ms-PL
| programming language = .NET Languages
| website = mef.codeplex.com
}}

Managed Extensibility Framework (MEF) is a component of .NET Framework 4.0 aiming to create lightweight, extensible applications. It aims to allow .NET application developers to discover and use extensions with no configuration required. It also aims to let extension developers encapsulate code easily and avoid fragile hard dependencies. Furthermore, it aims to allow extensions to be reused across applications. MEF was introduced as a part of .NET 4.0 and Silverlight 4.

What problems does MEF aim to solve?

MEF aims to solve the runtime extensibility problem. Without MEF, any application that wants to support a plugin model needs to create its own infrastructure from scratch. Those plugins will often be application-specific and cannot be reused across multiple implementations.

  • MEF aims to provide a standard way for the host application to expose itself and consume external extensions. Extensions, by their nature, could be reused amongst different applications. However, an extension can still be implemented in a way that is application-specific. Extensions themselves can depend on one another and MEF aims to make sure they are wired together in the correct order, sparing the developer from doing it manually.
  • MEF offers a set of discovery approaches for the application to locate and load available extensions.
  • MEF allows tagging extensions with additional metadata which aims to facilitate rich querying and filtering.

How does MEF work?

Roughly speaking, MEF's core consists of a catalog and a CompositionContainer. A catalog is responsible for discovering extensions and the container coordinates creation and satisfies dependencies.

  • MEF's first-class citizen is the ComposablePart class. A composable part offers up one or more Exports, and may also depend on one or more externally provided services or Imports. A composable part also manages an instance, which can be an object instance of a given type (it is in the default MEF implementation){{Clarify|date=November 2013}}. MEF, however, is extensible and additional ComposablePart implementations can be provided as long as they adhere to the Import/Export contracts.
  • Exports and imports each have a Contract. Contracts are the bridge between exports and imports. An export contract can consist of further metadata that can be used to filter on its discovery. For example, it might indicate a specific capability that the export offers.
  • MEF's container interacts with Catalogs to have access to composable parts. The container itself resolves a part's dependencies and exposes Exports to the outside world. Composable part instances may be added directly to the container.
  • A ComposablePart returned by a catalog will likely be an extension to the application. It might have Imports (dependencies) on components the host application offers, and it's likely to Export others.
  • The default MEF composable part implementation uses attribute-based metadata to declare exports and imports. This allows MEF to determine which parts, imports, and exports are available through discovery.

References

External links

  • MEF at CodePlex
  • [https://docs.microsoft.com/en-us/dotnet/framework/mef/index Managed Extensibility Framework Overview]
  • Building Composable Apps in .NET 4 with the Managed Extensibility Framework
  • Gentle Introduction to MEF - Part One
{{.NET Framework}}{{Portal bar|.NET Framework}}

3 : .NET Framework terminology|C Sharp libraries|Software using the MS-PL license

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/13 18:48:40