2011-12-07 31 views
4

我有一個使用PRISM的WPF桌面應用程序,有12個模塊互不依賴,每次啓動shell時,模塊都已加載,重點是我想知道哪個模塊最後加載所以我可以開始一個行動。我怎麼能確定這一點?我怎麼知道我的所有模塊是否裝入棱鏡4?

+0

你的意思是說你想在所有模塊加載時觸發動作?你的代碼在所有模塊加載的地方都有嗎?或者你可以記錄模塊的初始化? – erikH

+0

我喜歡在加載所有模塊時引發事件。應用程序不知道將要加載多少個模塊,這些模塊位於「。\ modules」目錄中。 –

回答

9

覆蓋Bootstrapper.InitializeModules,調用基地,然後ACTION!

+0

噗! ,我要檢查一下...... –

+1

謝謝erikH,這正是我所需要的。 –

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

相關問題