Benefits b/w methods of loading modules in Bootstrapper (GetModuleCatalog())

Topics: Prism v2 - WPF 3.5
Mar 17, 2010 at 3:57 PM

Can anyone shed some light on the key differences b/w the options for loading the module catalog in the bootstrapper?  Specifically the 3 methods below (are there others?):

    return new ConfigurationModuleCatalog();  //load modules from configuration file

    return new ModuleCatalog().AddModule(typeof(MyModule)); //manually load modules

    return new DirectoryLookupModuleEnumerator(@".\Modules");  //load from directory

I understand the basic difference of where the modules are coming from and how they are loaded, but what are the advantages/disadvantages b/w them?  Is there much difference other than how

you choose to structure your modules?

Thanks.

 

Mar 17, 2010 at 8:57 PM

Hi,

The main difference between having the modules declared in code, loading from a directory and loading from a configuration file is that, with the latter one, there is no need to rebuild your solution to deploy different modules (the first two depend on the code, either to add directly to ModulesCatalog or for attributes).

If you use Directory or Configuration module loading your Shell project does not need to have a reference to every other module (which is not the case if you declare modules in code).

Some other benefits to each module loading approach are explained in this document.

It is also possible to load modules from XAML in WPF. Some time ago I blogged about it, as Prism does not provide a QS that shows this scenario.

Please let me know if this helps.

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

May 27, 2010 at 8:42 PM

Hi Damian,

I read the article of yours and find it to be interesting. I was just wondering if I can use it for my requirement which is as below - 

I have a pre-defined set of modules which needs to be loaded based on the user logging in. So if the user "Mike" is logging in, I will have to load some set of modules based on his credentials or if the user "John" logs in he needs to be provided with a different set of modules. So I was thinking to maintain separate XAML files(one each based on the requirement) which will have the definitions for the modules to be loaded. In such case, I will have a single Shell which will be catering two different applications. Is this possible? Do I need to get the respective credentials in the GetModuleCatalog method to decide which module catalog to be loaded?

 

Thanks in advance.

Developer
Jun 1, 2010 at 7:47 PM

Hi,

The scenario you are describing is possible. You could show a Login screen before loading the shell (as explained on this thread), and based on the credentials provided there, you could decide which module catalog to load in the GetModuleCatalog method.

I hope you find this helpful.

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