protected override void OnStartup(StartupEventArgs e) { var stateManager = new DefaultApplicationStateManger(); stateManager.GotToNewState(ApplicationState.BOOTSTRAPPING); try { base.OnStartup(e); ApplicationBootstrapper bootstrapper = new ApplicationBootstrapper(stateManager); bootstrapper.Run(); this._applicationContent = bootstrapper.ContentContainer; stateManager.GotToNewState(ApplicationState.RUNTIME); Current.MainWindow = (Window)bootstrapper.CurrentShell; Current.MainWindow.Show(); } #pragma warning disable 168 catch (Exception exception) #pragma warning restore 168 { stateManager.GotToNewState(ApplicationState.FATAL_ERROR); /*TODO: do some work here on notifying a user about the failure*/ throw; } }
/// <summary> /// Run the bootstrapper process. /// </summary> /// <param name="runWithDefaultConfiguration"> /// If <see langword="true" />, registers default Composite Application Library services in the container. This is the default behavior. /// </param> public override void Run(bool runWithDefaultConfiguration) { base.Run(runWithDefaultConfiguration); this._contentContainer = new ApplicationContentContainer(this.Container); }
/// <summary> /// Raises the <see cref="E:System.Windows.Application.Exit" /> event. /// </summary> /// <param name="e"> /// An <see cref="T:System.Windows.ExitEventArgs" /> that contains the event data. /// </param> protected override void OnExit(ExitEventArgs e) { this._applicationContent.Dispose(); this._applicationContent = null; base.OnExit(e); }