我有一个使用 PRISM 的 WPF 桌面应用程序,有 12 个相互不依赖的模块,每次我启动 shell 时,都会加载模块,关键是我想知道最后加载了哪个模块所以我可以开始一个动作。我怎么能确定这个?
问问题
2139 次
2 回答
9
覆盖 Bootstrapper.InitializeModules,调用 base,然后 ACTION!
于 2011-12-07T19:38:27.387 回答
0
扩展 erikH 的答案(谢谢,顺便说一句),假设您是从默认的 UnityBootstrapper 派生的,这里是调用通常被覆盖的方法的顺序:
//0
public override void Run(bool runWithDefaultConfiguration)
{
base.Run(runWithDefaultConfiguration);
//this is our last opportunity to hook into the PRISM bootstrapping sequence; at this point every very other base-overridden
//method has been executed
}
//1
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
//add modules...
}
//2
protected override void ConfigureContainer()
{
base.ConfigureContainer();
//register everything with the container...
}
//3
protected override DependencyObject CreateShell()
{
return Container.Resolve<ShellView>(); //resolve your root component
}
//4
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)Shell;
App.Current.MainWindow.Show();
}
//5
protected override void InitializeModules()
{
base.InitializeModules();
}
请注意,这适用于 PRISM 4 和 5
于 2015-05-15T17:40:57.810 回答