是MEF OSGi for .NET吗? [英] Is MEF OSGi for .NET?

查看:132
本文介绍了是MEF OSGi for .NET吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想围绕管理可扩展性框架 MEF ),并进行深入研究。我有一个Eclipse的背景,所以在我的大脑我现在有这样的方程:

I'm just trying to get my head around the Managed Extensibility Framework (MEF) at the moment and digging into a bit. I have an Eclipse background so in my brain I currently have the equation:


MEF =〜OSGi for .NET

根据我迄今为止听到的内容。我是正确的吗?

Based on what I have heard so far. Am I on the right lines?

推荐答案

Scott Hanselman帮助他突出了他的 podcast 148 与Glenn Block。

Scott Hanselman helped to highlights the specifics about MEF in his podcast 148 with Glenn Block.

与OSGi相比,MEF建立在反转控制之上, OSGi 不是:它(OSGi)将发现新的捆绑通过基于生命周期层的不同机制。

Compared to OSGi, MEF is built upon "Inversion of Control" and OSGi is not: it (OSGi) will discover new bundle through a different mechanism based on a Life Cycle Layer.


MEF 专注于应用程序可扩展性。它使用DI作为组合不同扩展名的策略,但是它本身不是一个通用的DI容器。

MEF is focused on application extensibility. It uses DI as a strategy for composing the different extensions, however it is not in itself a generic DI container.

由于最后一点可能令人困惑,播客的成绩单可以帮助您: p>

Since the last point can be confusing, the transcripts of the podcast can help:


我基本上定位它的方式,两者之间的区别是,IoC容器真的是关于管理已知的在不同环境中的事情集合,像我想要在我的磁盘环境中的记录器,我想在我的测试环境中一个模拟记录器。

The way I basically position it though, the difference between the two, is that IoC containers are really about managing a known set of things in different environments, like I want a logger in my disk environment, I want a mock logger in my test environment.

所以MEF真的是关于管理一个未知的东西,归结为什么是在IoC容器中我倾向于做一个基于会议或注册的具体注册机制,说这是记录器的意思,这就是这个意思,这就是这个意思。

So MEF is really about managing an unknown set of things and what that boils down to is that in an IoC Container I tend to do either a convention-based or a registration, specific registration mechanism, to say here's what logger means, here's what this means, here's what that means.

MEF在代码中使用代码,发现机制和注释,它们是
属性,系统中出现的是哪里,那就是那里。

MEF uses the code and a discovery mechanism and annotations on the code, which are attributes, where whatever shows up in the system, that's what's there.

再一次,把它带到更高的层次,这是关于你使用MEF真正管理一组未知的东西,你使用IoC容器来管理一组已知的东西。

So again, taking it to a higher level, it's about you use MEF to really manage a set of unknown things, you use IoC Containers to manage a set of known things.

结论: )主要区别是发现原则(IoC与生命周期)

Conclusion: (one of) the main difference is the discovery principle (IoC vs. lifecycle)

这篇关于是MEF OSGi for .NET吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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