Fork me on Github

Prism_模块化

一、添加引入导入(不推荐)

1.将要导入模块的输出类型改为类库

2.添加要导入模块的配置文件

public class ModuleAProfile : IModule
{
    public void OnInitialized(IContainerProvider containerProvider)
    {
        
    }

    /// <summary>
    /// 依赖注入
    /// </summary>
    /// <param name="containerRegistry"></param>
    /// <exception cref="NotImplementedException"></exception>
    public void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.RegisterForNavigation<UCA>("A");
    }
}

3.添加要导入模块的引入

 4.在app文件中添加模块

protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
    moduleCatalog.AddModule<ModuleAProfile>();
    moduleCatalog.AddModule<ModuleBProfile>();
    base.ConfigureModuleCatalog(moduleCatalog);
}

二、通过配置文件导入

1..将模块生成的DLL文件添加到项目目录

2.app文件中添加模块

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

 

posted @ 2025-05-11 18:39  昂昂呀  阅读(29)  评论(0)    收藏  举报