我在一个应用程序中使用Prism,需要一个登录对话框。为了验证登录,我需要初始化一些由Prism / MEF加载的应用程序数据,所以我不能将其放在App.xmal.cs OnStartUp中。因此,我将登录对话框放在引导程序的InitializeShell中,如下所示:
protected override void InitializeShell()
{
Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
//// Authenticate the current user and set the default principal
LoginDialog auth = new LoginDialog();
auth.WindowStartupLocation = WindowStartupLocation.CenterScreen;
bool? dialogResult = auth.ShowDialog();
// deal with the results
if (dialogResult.HasValue && dialogResult.Value)
{
base.InitializeShell();
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
}
else
{
Application.Current.Shutdown(-1);
}
#if SILVERLIGHT
Application.Current.RootVisual = (Shell)this.Shell;
#else
Application.Current.MainWindow = (Shell)this.Shell;
Application.Current.MainWindow.Show();
#endif
}
我很难评估是否存在任何陷阱或缺点,有人有评论吗?