Prism v4:Unity 还是 MEF?

发布于 2024-10-05 22:15:06 字数 1108 浏览 3 评论 0原文

我下载了 Prism v4< /a> 并运行安装程序。我进入该目录并运行以下两个批处理文件:

  • 仅桌面 - 使用 Mef QuickStart.bat 打开模块化
  • 仅桌面 - 使用 Unity QuickStart.bat 打开模块化

当我编译这些应用程序时,我没有看到任何真正的区别。我搜索了 MEF 与 Unity,发现了一些优点/缺点,但没有具体说明在 Prism 中使用是否“更好”(我知道这是主观的)。我想如果我列出我的要求,也许有人可以指出我要使用的正确技术(即使它不是 Prism 4)。

  • 该应用程序将用 WPF(不是 Silverlight)编写。
  • 主要应用程序将非常薄。
  • 主应用程序将使用 Web 服务来构建用户可以访问的“应用程序/模块”菜单。
  • “应用程序/模块”将完全包含在其他托管库中。
  • 主应用程序通过反映到这些 DLL 中来获取视图和视图模型。
  • 主应用程序应该将日志记录等服务提供给这些“应用程序/模块”。

例如:

基本用户可能具有以下选项:

  • 仅查看地址记录

所有与地址相关的项目都位于 Address.dll 内。

高级用户可能有以下选项:

  • 新地址记录
  • 打开地址记录(更新/删除)
  • 管理用户

所有与地址相关的项目都在 Address.dll 内。
所有与管理相关的项目都在 Admin.dll 内。

该应用程序实际上不应引用这些 DLL 中的任何一个,我计划反映到它们中,以便如果有 100 个不同的模块并且用户只能访问其中的 2 个,则只下载和使用其中的 2 个。而有权访问其中 10 个的用户将获得这 10 个。

我已经解决了通过 WebService 下载 DLL 的问题。 :)

I downloaded Prism v4 and ran the installer. I went into the directory and ran the two following batch files:

  • Desktop only - Open Modularity With Mef QuickStart.bat
  • Desktop only - Open Modularity With Unity QuickStart.bat

When I compile these applications, I don't see any real difference. I've searched for MEF vs Unity and I've found some pros/cons, but nothing that specifically states whether one is "better" (and I know that is subjective) with use in Prism. I guess perhaps if I list my requirements someone can point me to the correct technologies to use (even if it's not Prism 4).

  • The application is to be written in WPF (NOT Silverlight).
  • The main application will be extremely thin.
  • The main application will use a Web Service to build the menu of the "apps/modules" a person has access to.
  • The "apps/modules" will be completely contained in other managed libraries.
  • The main application gets views and viewmodels by reflecting into these DLLs.
  • The main application should feed in services for logging, etc. into these "apps/modules".

For example:

A basic user might have the options of:

  • ViewOnly Address record

All items Address related are within Address.dll.

An advanced user might have the options of:

  • New Address record
  • Open Address record (update/delete)
  • Manage users

All items Address related are within Address.dll.
All items Manage related are within Admin.dll.

The app should not actually reference either of these DLLs, I plan to reflect into them so that if there are 100 different modules and a user only has access to 2 of them, only 2 of them are downloaded and used. Whereas a user that has access to 10 of them gets those 10.

I've already solved the downloading DLL via WebService. :)

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

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

发布评论

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

评论(4

嗫嚅 2024-10-12 22:15:06

没有一个是“更好”的:它们是不同的东西。

在我看来,您的选择应该仅由您的需求决定。根据您在此处发布的要求,我建议您使用 MEF,因为您的模块包含在 DLL 中,并且主应用程序不知道要加载的模块。这些任务就是 MEF 存在的原因。

无论如何,您可以同时使用它们:MEF 用于模块化,Unity 用于利用依赖注入(可测试性、可重用性……)

None is "better": they are different things.

IMO your choice should be driven only by your requirements. Based on the requirements you posted here I would suggest you to use MEF, because you have modules contained in DLLs and the main app is unaware of modules to load. Those tasks are the reason that why MEF exists.

Anyway you could use them both: MEF for modularity and Unity to take advantages of dependency injection (testability, reusability, ...)

眼角的笑意。 2024-10-12 22:15:06

如果所有模块没有与应用程序同时重新编译,那么 MEF 为您提供了很多方法来应对主应用程序中不断变化的界面。否则,MEF可能比您需要的更复杂。

If all the modules are not recompiled at the same time as the app, then MEF gives you lots of ways to cope with changing interfaces in the main app. Otherwise MEF may be more complex then you need.

浮光之海 2024-10-12 22:15:06

我已经使用 Unity 和 PRISM 一年多了,但我注意到一些严重的内存泄漏问题。因此我决定尝试一下 PRISM 4 和 MEF。我所做的首先是将我的应用程序转换为使用 PRISM 4 和 Unity。然后我将一个分支转换为使用 MEF。
这可能听起来很有趣,但 MEF 似乎在处理内存消耗和释放方面比 Unity 更好。

很高兴听到其他人是否也有过同样的经历?

I've been using Unity over a year with PRISM but I've noticed some serious memory leaking issues. Hence I decided to give PRISM 4 and MEF a go. What I've done is firstly converting my app to use PRISM 4 with Unity. Then I converted a branch to use MEF.
It may sound funny but MEF seems to handle memory consumption and release somehow better than Unity.

Would be nice to hear whether others have made the same experience?

独自←快乐 2024-10-12 22:15:06

关于你问MEF和UNITY是否可以很好地合作,我可以告诉你,他们的合作非常好。我开发了一个使用 PRISM、Unity 和 MEF 的概念验证应用程序。

Regard to your question whether MEF and UNITY can work nicely with each other, i can tell you that they are working really well with each other. I have developed a proof of concept application which used PRISM, Unity and MEF.

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