我有一个使用PRISM的WPF桌面应用程序,有12个模块不相互依赖,每次启动shell时,模块都已加载,重点是我想知道哪个模块加载到了最后,我可以开始行动。我怎么能确定这个?
答案 0 :(得分:9)
覆盖Bootstrapper.InitializeModules,调用base,然后执行ACTION!
答案 1 :(得分: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