Prism v4:Unity还是MEF? [英] Prism v4: Unity or MEF?

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

问题描述

我下载了 Prism v4 并运行安装程序.我进入目录并运行了以下两个批处理文件:

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

  • 仅台式机-使用Mef QuickStart.bat打开模块化
  • 仅台式机-使用Unity QuickStart.bat打开模块化

当我编译这些应用程序时,我看不出任何真正的区别.我已经搜索了MEF vs Unity,并且发现了一些优点/缺点,但是没有什么能特别说明在Prism中使用它是否更好"(并且我知道那是主观的).我猜想,如果我列出了我的要求,那么有人可以指出我要使用的正确技术(即使它不是Prism 4).

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

  • 应用程序将使用WPF编写( Silverlight).
  • 主要应用程序将非常薄.
  • 主应用程序将使用Web服务来构建人们可以访问的应用程序/模块"菜单.
  • 应用/模块"将完全包含在其他托管库中.
  • 主应用程序通过反映到这些DLL中来获取视图和视图模型.
  • 主应用程序应在这些应用程序/模块"中提供用于日志记录等的服务.
  • 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".

例如:

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

A basic user might have the options of:

  • 仅查看地址记录

与地址相关的所有项目都在Address.dll中.

All items Address related are within Address.dll.

高级用户可以选择以下选项:

An advanced user might have the options of:

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

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

该应用程序实际上不应引用这两个DLL中的任何一个,我计划对其进行反映,以便如果有100个不同的模块,并且用户只能访问其中的2个,则仅下载和使用其中的2个.有权访问其中10个用户的用户则获得了10个用户.

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.

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

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

推荐答案

没有一个更好"的东西:它们是不同的东西.

None is "better": they are different things.

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

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.

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

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

这篇关于Prism v4:Unity还是MEF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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