Prism 7 - Merge ConfigurationModuleCatalog with DirectoryModuleCatalog

空扰寡人 提交于 2019-12-11 02:23:17

问题


I would like to use both:

protected override IModuleCatalog CreateModuleCatalog()
{
    return new ConfigurationModuleCatalog();
}

and

protected override IModuleCatalog CreateModuleCatalog()
{
    return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
}

I found this question:

Prism 6 - Merge ConfigurationModuleCatalog with DirectoryModuleCatalog

But the link in the answer is dead, it returns 404.

I also searched for the "AggregateCatalog" that was mentioned in the answer - I looked here:

https://github.com/PrismLibrary/Prism/tree/master/Source/Prism/Modularity

and here:

https://github.com/PrismLibrary/Prism/tree/master/Source/Wpf/Prism.Wpf/Modularity

but I didn't find it...

Is there any way to do this in Prism 7 with Unity?


回答1:


Try this:

protected override IModuleCatalog CreateModuleCatalog()
{
    var a = new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
    var b = new ConfigurationModuleCatalog();

    return new ModuleCatalog(a.Modules.OfType<ModuleInfo>().Concat(b.Modules).OfType<ModuleInfo>());
}


来源:https://stackoverflow.com/questions/54571914/prism-7-merge-configurationmodulecatalog-with-directorymodulecatalog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!