Prism v4 使用 DirectoryModuleCatalog 按需加载模块 [英] Prism v4 Loading modules on demand with DirectoryModuleCatalog

查看:63
本文介绍了Prism v4 使用 DirectoryModuleCatalog 按需加载模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的引导程序中,我有以下代码来创建我的目录模块目录

In my bootstrapper I have the following code to create my Directory ModuleCatalog

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

但是我的所有模块似乎在 shell 创建时都在加载.如何在仍然使用 DirectoryModuleCatalog 的同时按需加载它们?

but all my modules seem to be loading when the shell gets created. How can I load them on demand while still using the DirectoryModuleCatalog?

推荐答案

我不记得确切的名称,但在 Prism v2 中,在实现 IModule 的类上放置了一些属性,以标记要按需加载的模块.

I don't remember the exact name, but in Prism v2 there were attributes that were placed on classes that implemented IModule to mark the modules to load on demand.

查看 Prism 文档的名称.

Check the Prism docs for their name.

编辑:刚刚检查了 Prism 代码.属性的类名是ModuleAttribute,用法如下:

EDIT: Just checked the Prism code. The class name for the attribute is ModuleAttribute and the usage is the following:

[Module(ModuleName = "MyModule", OnDemand = true)]
public class MyModule : IModule
{
   ...
}

谢谢,达米安

这篇关于Prism v4 使用 DirectoryModuleCatalog 按需加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆