ViewDiscoverComposition - How are the modules discovered/defined?

Topics: Prism v2 - WPF 3.5
Apr 22, 2010 at 2:54 AM

Hello,

In the documentation it indiactes that a module is defined in one of four ways:

- Defined in code <-- I would expect to see an override of GetModuleCatalog

- Defined in xaml <-- I would expect to see a ModuleCatalog.xaml

- Read from configuration file <--  I would expect to see an App.Config

- Discovering all modules in a directory <-- I would expect to see attributes on the modules defining the dependencies

I don't see any of these being done; can someone enlighten me?  I don't understand how the container knows how to inject the dependencies into the constructor of the modules when it does:

IModule employeeModule = this.Container.Resolve<EmployeeModule>(); 

I looked at the StockTraderRI and it appears that the modules are defined in code, but i'm still not sure I understand how the UnityContainer knows how to inject dependencies here.

Thanks,

Steve


Apr 22, 2010 at 10:50 PM

Hi Steve,

To check how each of the Module Loading approaches work, you can take a look at the Modularity Quickstarts that come with Prism. For WPF there is one for each of the approaches you mentioned (except for XAML) and you will be able to get a good idea of how they work. The reference implementation is populating the module catalog in the GetModuleCatalog method from the StockTraderRIBootstrapper class (the application’s launching point) inside the StockTraderRI project.

Regarding the injection of dependencies, the Unity container uses reflection to recognize the different dependencies of a particular class and searches its registered type mappings to satisfy those dependencies. There are different ways to mark dependencies in a class, which you can read about in the Unity documentation. If you have a Unity specific question, you can ask it in the Unity forums.

For some more information about getting started with Prism and the different concepts it brings to the table you can check out this blog post.

Please let me know if this helps.

Damian Schenkelman 
http://blogs.southworks.net/dschenkelman