MEF provides several capabilities that Unity does not question

Topics: Prism v4 - Silverlight 4
Mar 28, 2011 at 9:29 PM

In prism 4 documentation in chapter 3: Managing Dependencies Between Components there is statement:

MEF provides several capabilities that Unity does not:

  • It uses XAP file download and assembly discovery.

Can someone explain me why ?   Unity can download xap on demand....

Another thing  somewhere in doc - Mef can not use xaml configuration..... again not right....Mef can use the same module catalog as unity.....

or i missed something?

 

 

Developer
Mar 29, 2011 at 2:19 PM
Edited Mar 29, 2011 at 2:21 PM

Hi,

MEF provides an AssemblyCatalog, DirectoryCatalog and DeploymentCatalog by its own (more information here). While the scenario of downloading a xap file on demand is supported using Unity as well (due to the XapModuleTypeLoader class in the Modularity folder of the Prism.Silverlight project in the Prism Library), what the documentation seems to be explaining are the native capabilities of MEF and its differences with Unity. It's worth noting that the Modularity mechanisms in Prism provide an abstraction over the container mechanisms for these scenarios. This is the reason why there is a MefXapModuleTypeLoader, as well as a MefModuleInitializer, a MefModuleManager, and so forth.

As for specifying modules in a xaml file, there should be no impediment for using that approach in a composite application using MEF. For example, the Modularity QuickStart with MEF uses a xaml catalog (ModulesCatalog.xaml) to define some of the modules.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Mar 29, 2011 at 2:52 PM

so it means that using prism there is no difference what to use - mef or unity..

Except export attribute in mef (and some other small differences ) there is no difference with unity...right?

Developer
Mar 29, 2011 at 3:03 PM
Edited Mar 29, 2011 at 3:04 PM

There should be no major differences in using Unity or MEF for Prism-related functionality, since Prism is container agnostic. Therefore, the choice between them could be based on personal preference.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Mar 29, 2011 at 3:08 PM

then I don't understand why some people are screaming that mef is the only way to go.

Thanks.