MEF:棱镜的替代品?

发布于 2024-08-03 05:45:23 字数 35 浏览 8 评论 0原文

MEF 在多大程度上(如果有的话)可以替代 PRISM?

To what extent, if any, is MEF a replacement for PRISM?

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

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

发布评论

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

评论(4

长梦不多时 2024-08-10 05:45:23

今天我想说 Prism 和 MEF 是相辅相成的。正如 Prism 和 Unity 一样。 Prism 引入了一组特定服务,例如 RegionManager、DelegateCommand 和 EventAggregator,它们有助于构建复合应用程序。另一方面,MEF 是一种更通用的组合机制,用于应用程序和框架的可扩展性,无论它们是否是复合的。 MEF 的主要区别在于它的可发现性,这意味着它可以动态地发现所有可用的部分。

您可能有兴趣查看 MEF contrib 项目 (mefcontrib.codeplex.com),其中包含 Unity 和 MEF 的集成层。通过该扩展,Unity 在幕后管理 MEF,因此您不必与两个容器竞争。优点是它允许您使用 Unity 来实现通用 Pocos,并使用 MEF 来发现扩展。因此,由于 Prism 目前是在 Unity 上构建的,因此您可以使用它来利用 MEF。要使用 contrib 项目,您必须对 Unity Bootstrapper 进行一些细微的更改,但这应该是相当简单的。

肯定有一些重叠。最突出的地方是模块。 Prism 使用 IModule 作为发现手段。在MEF中,任何组件都可以是一部分并且可以动态发现。这意味着使用 MEF,您可以从上到下实现模块化,而使用 Prism,模块是更细粒度的单元。复合应用程序绝对是 MEF 期间我们关注的一个领域。随着时间的推移,您很可能会看到越来越多的支持在 MEF 本身内构建这些类型的应用程序。我们正在与 p&p 合作,以确保在这种情况发生时能够顺利过渡。

Today I would say Prism and MEF complement each other. Just as Prism and Unity. Prism introduces a set of specific services like RegionManager, DelegateCommand, and EventAggregator which aid in building composite apps. MEF on the other hand is a more general composition mechanism for extensibility of applications and frameworks whether they are composites or no. The key distinguisher about MEF is it's discoverability which means that it can go out and discover all the available parts dynamically.

You might be interested in checking out the MEF contrib project (mefcontrib.codeplex.com) which contains an integration layer for Unity and MEF. With that extension, Unity manages MEF behind the scenes, so you are not contending with two contianers. The advantage is it allows you to use Unity for general Pocos, and MEF for discovery of extensions. Thus as Prism is currently built on Unity, you can use it to leverage MEF. To use the contrib project, you'll have to make some slight changes to your Unity Bootstrapper, but it should be fairly trivial.

There is definitely some overlap. The place where it's the most prominent is with regard to modules. Prism uses an IModule as a means of discovery. In MEF, any component can be a part and can be dynamically discovered. This means with MEF you have modularity from top to bottom, wheras with Prism, modules are more granular units. Composite applications is definitely an area we are conerned with on the MEF time. Over time it is quite likely you will see more and more support for building those types of apps within MEF itself. We're working with p&p to ensure that as that happens, there is a smooth transition.

嘿看小鸭子会跑 2024-08-10 05:45:23

编辑:不要阅读此答案。这是令人尴尬的错误。我是失败者。阅读下面 Glenn Block 的文章。

这并不明显,但这是同一个问题:
托管扩展性框架 (MEF) 与复合 UI 应用程序块(CAB)

重复帖子中的共识是 MEF 和 Prism 以不同的方式提供相同的基本功能集,除了 Prism 提供 事件聚合器,它是应用程序组件之间通信的发布-订阅方式。不过,您可以将其与 MEF 一起使用。这实际上很大程度上取决于偏好。

Edit: Do not read this answer. It is embarrassingly wrong. I am fail. Read Glenn Block's below.

It's not obvious, but this is the same question:
Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB)

Consensus in the duplicate post is that MEF and Prism provide the same basic set of functionality in different ways, except that Prism provides the Event Aggregator, which is a pub-sub means of communication between application components. You can use this with MEF, however. It's pretty much up to preference, really.

奢欲 2024-08-10 05:45:23

看看这个有关 MEF 和 Prism 的 Sparkling Client 播客

Take a look at this Sparkling Client podcast on MEF and Prism.

红尘作伴 2024-08-10 05:45:23

MEF 永远不会取代 prism

MEF 是一个依赖注入管理器。它不是一个依赖注入容器。
MEF 提供使用属性以声明方式分配导出和导入的能力。

Prism with MEF 使您能够自动发现 dll,并能够通过添加或删除 dll 来添加和删除插件。
棱镜框架提供了事件聚合器、区域管理器、服务定位器。

您可以在没有 MEF 的情况下使用棱镜。还有各种其他选项,例如 ninject、unity 和其他 DI 容器。

您可以将 MEF 与 prism 结合使用来构建基于插件的可扩展应用程序。

MEF will never replace prism

MEF is a dependency injection manager.its not a dependency injection container.
MEF provides ability to assign exports and imports delclaritively using attributes.

Prism with MEF gives you ability to ability to auto discover dlls and ability to add and remove plugins by adding or deleting dlls.
Where as prism framework gives event aggregator, region manager, service locator.

You can use prism without MEF. There are various other options like ninject, unity and other DI containers.

You can use MEF with prism for building plugin based extensible applications.

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