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

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

问题描述

MEF(Managed Extensibility Framework)解决了哪些现有IoC/DI容器无法解决的问题?

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

推荐答案

MEF 的主要目的是可扩展性;当应用程序的作者和插件(扩展)的作者不同并且除了发布的界面之外彼此没有特定的知识时,用作插件"框架(合同) 库.

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.

MEF 解决的另一个问题空间与通常的 IoC 疑点不同,也是 MEF 的强项之一,是 [扩展] 发现.它有很多可扩展的发现机制,可以对可以与扩展关联的元数据进行操作.来自 MEF CodePlex 站点:

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 允许使用附加元数据标记扩展,这有助于丰富的查询和过滤"

结合延迟加载标记扩展的能力,能够在加载之前查询扩展元数据为一系列有趣的场景打开了大门,并大大启用了诸如[插件]之类的功能版本控制.

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 还具有合同适配器",允许对这些转换的详细信息进行改编"或转换"(从类型> 到类型).与发现"的含义和含义相关的合同适配器开辟了另一个创意前沿.

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.

再次强调,MEF 的意图"紧密关注匿名插件的可扩展性,这与其他 IoC 容器有很大不同.因此,虽然 MEF 可用于组合,但这只是其功能相对于其他 IoC 的一小部分交集,我怀疑我们会在未来看到很多乱伦的相互作用.

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(托管可扩展性框架)与 IoC/DI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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