在一个项目中使用 MEF 和 Prism (CAL) 是否可能(且合理)?

发布于 2024-07-29 21:34:16 字数 277 浏览 1 评论 0原文

我目前正在使用 Prism (CAL) 开发一个 WPF 项目,想知道在一个项目中同时使用 Prism 和 MEF 是否是一个好主意。

我会使用 Prism 来实现模块化,使用 MEF 来实现可扩展性。 我的项目是一个类似绘画的应用程序,因此 Prism 将提供模块分离(工具箱、画布作为模块等),而 MEF 将用于为要绘画的新形状(即矩形、圆形......)提供扩展点。

这有意义吗?或者我只能通过 Prism 获得类似的功能吗?

预先致谢并致以诚挚的问候, 克里斯楚

I am currently working on a WPF project using Prism (CAL) and am wondering if it is a good idea to use both Prism and MEF in one project.

I would use Prism for modularity and MEF for extensibility. My project is a paint-like application so Prism would provide the module-separation (toolbox, canvas as modules etc.) and MEF would be used to provide an extensibility point for new shapes to paint (ie. rectangle, circle..).

Would that make sense or can I get similar functionality with Prism only?

Thanks in advance and best regards,
crischu

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

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

发布评论

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

评论(2

桃扇骨 2024-08-05 21:34:16

这样做是合理的,我们有几个客户在这样做。 MEF 是 .NET Framework 4.0 以及下一版本 Silverlight 的一部分。 目前,我们在 Codeplex 上发布了适用于 .NET 3.5 的 MEF。

就带有 MEF 的 Prism 而言,此时的挑战是您需要编写一堆代码,因为 Prism 还没有实现与 MEF 通信所需的服务。

一个选择是使用我们拥有的 MEF/Unity 集成层MEF Contrib (mefcontrib.codeplex.com)。 它使 Unity 和 MEF 能够相互通信,因此您可以通过 Unity 桥将现有的 Prism 源与 MEF 一起使用。

我们正在与 p&p 合作,为 MEF 提供直接支持。

谢谢
格伦

It is reasonable to do, and we have several customers doing it. MEF is part of the .NET Framework 4.0, as well as the next version of Silverlight. We currently ship MEF for .NET 3.5 on Codeplex.

As far as Prism with MEF, the challenge at this point is you need to write a bunch of code as Prism does not yet have implementations of the services necessary to talk to MEF

One option is to use the MEF/Unity integration layer we have in MEF Contrib (mefcontrib.codeplex.com). It enables Unity and MEF to talk back to one another, thus you can using the existing Prism source with MEF through the Unity bridge.

We are working with p&p to have direct supprot for MEF backed in.

Thanks
Glenn

扛刀软妹 2024-08-05 21:34:16

当然! 这是一件非常合适的事情。

MEF 看起来像是正在向 .NET Framework 迈进,所以我想说,这是公开插件表面积的一种非常好的方法,该插件表面积需要非常小的(且相对不变的)依赖项(仅在 MEF 上......而不是所有其他依赖项) Prism 附带的东西)为您的插件作者提供。

由于它将出现在 Framework 中,我敢打赌熟悉它的人会比熟悉 Prism 的人多。

Sure! That's a very appropriate thing to do.

MEF looks like it's heading for the .NET Framework so I'd say this was a really good way to expose a plugin surface area that requires a very small (and relatively unchanging) dependency (just on MEF... not all of the other stuff that comes along with Prism) for your plugin authors.

Since it's going to be in the Framework I'd wager more people will become familiar with it than they would Prism.

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