MEF: a replacement for PRISM?

懵懂的女人 提交于 2019-12-18 10:53:19

问题


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


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/1324702/mef-a-replacement-for-prism

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!