Reputation: 171
Problem:
If I use the DirectoryModuleCatalog, then the ModuleCatalog keeps empty, only after base.InitializeModules(); the modules are in the ModuleCatalog, but already initialized.
protected override IModuleCatalog CreateModuleCatalog()
{
var moduleCatalog = new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
return moduleCatalog;
}
protected override void InitializeModules()
{
// No Modules are in the list
// I aspect, that temp shall not empty, temp shall have the modules in the list of my directory, of the module shall not be initialized.
var temp = ModuleCatalog.Modules;
base.InitializeModules();
// Modules visible but already init done
}
If I add the modules by code to the ModuleCatalog, then of course my list is not empty
protected override IModuleCatalog CreateModuleCatalog()
{
Type module1Type = typeof(ModuleHelper);
string path = module1Type.Assembly.Location;
IModuleCatalog moduleCatalog = new ModuleCatalog();
moduleCatalog.AddModule(
new Prism.Modularity.ModuleInfo()
{
ModuleName = module1Type.Name,
ModuleType = module1Type.AssemblyQualifiedName,
Ref = new Uri(path, UriKind.RelativeOrAbsolute).AbsoluteUri
});
}
protected override void InitializeModules()
{
// temp is not empty
// Modules visible and init not done
var temp = ModuleCatalog.Modules;
base.InitializeModules();
}
Question:
Should the modules not in the list be, after the DirectoryModuleCatalog has been instantiated? Is this the normal behavior for the DirectoryModuleCatalog?
Upvotes: 0
Views: 426
Reputation:
It behaves exactly as expected. The Prism DirectoryModuleCatalog class allows you to specify a local directory as a module catalog in WPF. This module catalog will scan the specified folder and search for assemblies that define the modules for your application. To use this approach, you will need to use declarative attributes on your module classes to specify the module name and any dependencies that they have.
Upvotes: 1