MEF OSGi 是否适用于 .NET?

发布于 2024-07-16 02:13:02 字数 295 浏览 5 评论 0原文

我只是想了解 托管扩展性框架 (MEF)目前正在深入研究。 我有 Eclipse 背景,所以我脑子里目前有这样的方程:

MEF =~ OSGi for .NET

基于我到目前为止所听到的。 我的做法正确吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纸短情长 2024-07-23 02:13:02

Scott Hanselman 在他与 Glenn Block 的播客 148 中帮助强调了有关 MEF 的细节。

与 OSGi 相比,MEF 构建于“控制反转”之上,而 OSGi 则不然:它 (OSGi )将通过基于生命周期层的不同机制发现新的捆绑包。

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

由于最后一点可能会令人困惑,播客的转录可以提供帮助:

我基本上定位它的方式,两者之间的区别是,IoC 容器实际上是在不同环境中管理一组已知的事物,就像我想要在我的磁盘环境中使用记录器一样,我想要在我的测试环境中有一个模拟记录器。

因此,MEF 实际上是管理一组未知的事物,归根结底是,在 IoC 容器中,我倾向于执行基于约定的或注册、特定的注册机制,说这就是 logger 的意思,这就是这的意思,这就是这的意思。

MEF使用代码以及代码上的发现机制和注释,它们是
属性,系统中显示的内容就是该属性。

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

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

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

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 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.

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

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.

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 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.

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.

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

永言不败 2024-07-23 02:13:02

请注意,OSGi 的设计使得 IoC 容器可以作为模块在其之上提供,实际上,OSGi 有多个可用的 IoC 容器以及其他机制:DS、iPOJO、Blueprint 以及毫无疑问的其他机制。

Notice that OSGi is designed so that an IoC container can be provided on top of it as a module, actually, there are multiple IoC containers for OSGi available as well as other mechanisms: DS, iPOJO, Blueprint, and undoubtedly others.

苦行僧 2024-07-23 02:13:02

只是偶然发现了这一点,但 Prism 似乎是最接近 OSGi 的东西在.NET中我见过! 查看他们的模块化应用程序开发部分在文档中。

只需看看他们的模块依赖关系示例(几乎相当于捆绑包!):

<modules>
  <module assemblyFile="Modules/ModuleD.dll" moduleType="ModuleD.ModuleD, ModuleD" moduleName="ModuleD">
    <dependencies>
      <dependency moduleName="ModuleB"/>
    </dependencies>
</module>

在 Microsoft,Patterns & 似乎已经结束了。 实践团队相当于 OSGi 联盟。

Just stumbled upon this, but Prism seems to be the closest thing to OSGi in .NET I've seen! Look at their Modular Application Development section in the docs.

Just look at their example of the module dependencies (almost equivalent to bundles!):

<modules>
  <module assemblyFile="Modules/ModuleD.dll" moduleType="ModuleD.ModuleD, ModuleD" moduleName="ModuleD">
    <dependencies>
      <dependency moduleName="ModuleB"/>
    </dependencies>
</module>

It seems like over at Microsoft, the Patterns & Practices team serves as a kind-of OSGi Alliance equivalent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文