Topics: Prism v1, Prism v2 - Silverlight 2, Prism v2 - Silverlight 3, Prism v2 - Silverlight 4, Prism v2 - WPF 3.5, Prism v2 - WPF 4, Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jul 2, 2010 at 2:43 AM


     Is there any way to load the modules that mathc some specific condition by DirectoryModuleCatalog?

     For example,  There are Three modules now,

     public class Module A : IModule, ICustomInterface1{};

     public class Module B : IModule, ICustomInterface1{};

     public class Module C : IModule, ICustomInterface2{};

     When I state the application , I want to load the Module that derive from ICustomInterface1 , can we do that ? (Do not use the "OnDemad=true")


    Thank you.

Jul 8, 2010 at 3:20 PM


This is not supported in Prism out-of-the-box. As the DirectoryModuleCatalog has not filters, you could create your own ModuleCatalog implementation with this behavior.

Additionally, take into account that the DirectoryModuleCatalog implementation provided by Prism, does not support this functionality because it is expected to load all those modules in a module path. For example in deployments scenarios where catalogs are something planned/defined in advance.

If the application needs to load modules based on a particular logic you could to use any of these two approaches to fill the ModuleCatalog:

  1. Defining modules in code
  2. Defining modules in XAML

Another approach that might suite your scenario, is dealing with the condition in the Initialize method of all the modules. This approach has the disadvantage that the condition would be spread in all the modules.

I hope you can find this useful.

Fernando Antivero

Jul 8, 2010 at 11:36 PM

Thank you very much , I will check it as you said.