MEF(管理可扩展性框架)vs IoC / DI [英] MEF (Managed Extensibility Framework) vs IoC/DI

查看:131
本文介绍了MEF(管理可扩展性框架)vs IoC / DI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

MEF(管理可扩展性框架)解决了现有IoC / DI容器无法解决的问题? MEF的主要目的是可扩展性;作为应用程序的作者和插件作者(扩展名)之间的插件框架,不同于发布的界面之间彼此之间没有任何特定的知识( )库。



另一个问题空间MEF地址与通常的IoC嫌疑犯不同,MEF的优势之一是[扩展]发现。它具有大量,可扩展的发现机制,可根据您可以与扩展关联的元数据进行操作。从MEF CodePlex站点:



MEF允许使用附加元数据进行标记扩展,便于丰富的查询和过滤



结合延迟加载标记扩展的能力,能够将之前的扩展元数据询问加载打开了一大堆有趣的场景,并且基本上实现了诸如[插件]版本控制。



MEF还有合约适配器,其中扩展可以使用完整的适应或转换(从类型>键入)控制这些转换的细节。合同适配器相对于发现的意义和要求开辟了另一个创造性的前沿。



同样,MEF的意图非常侧重于匿名插件的可扩展性这与其他IoC容器有很大区别。因此,虽然MEF可以用于组合,但这只是其相对于其他IoC的能力的一小部分,我怀疑我们将会看到很多乱伦的互动。


What problems does MEF (Managed Extensibility Framework) solves that cannot be solved by existing IoC/DI containers?

解决方案

The principle purpose of MEF is extensibility; to serve as a 'plug-in' framework for when the author of the application and the author of the plug-in (extension) are different and have no particular knowledge of each other beyond a published interface (contract) library.

Another problem space MEF addresses that's different from the usual IoC suspects, and one of MEFs strengths, is [extension] discovery. It has a lot of, well, extensible discovery mechanisms that operate on metadata you can associate with extensions. From the MEF CodePlex site:

"MEF allows tagging extensions with additonal metadata which facilitates rich querying and filtering"

Combined with an ability to delay-load tagged extensions, being able to interrogate extension metadata prior to loading opens the door to a slew of interesting scenarios and substantially enables capabilities such as [plug-in] versioning.

MEF also has 'Contract Adapters' which allow extensions to be 'adapted' or 'transformed' (from type > to type) with complete control over the details of those transforms. Contract Adapters open up another creative front relative to just what 'discovery' means and entails.

Again, MEFs 'intent' is tightly focused on anonymous plug-in extensibility, something that very much differentiates it from other IoC containers. So while MEF can be used for composition, that's merely a small intersection of its capabilities relative to other IoCs, with which I suspect we'll be seeing a lot of incestuous interplay going forward.

这篇关于MEF(管理可扩展性框架)vs IoC / DI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆