/// <summary> /// Initializes a new instance of the <see cref="ShellService" /> class. /// </summary> /// <param name="typeFactory">The type factory.</param> /// <param name="keyboardMappingsService">The keyboard mappings service.</param> /// <param name="commandManager">The command manager.</param> /// <param name="splashScreenService">The splash screen service.</param> /// <param name="ensureStartupService">The ensure startup service.</param> /// <param name="applicationInitializationService">The application initialization service.</param> /// <param name="dependencyResolver">The dependency resolver.</param> /// <exception cref="ArgumentNullException">The <paramref name="typeFactory" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="keyboardMappingsService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="commandManager" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="splashScreenService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="applicationInitializationService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="dependencyResolver" /> is <c>null</c>.</exception> public ShellService(ITypeFactory typeFactory, IKeyboardMappingsService keyboardMappingsService, ICommandManager commandManager, ISplashScreenService splashScreenService, IEnsureStartupService ensureStartupService, IApplicationInitializationService applicationInitializationService, IDependencyResolver dependencyResolver) { Argument.IsNotNull(() => typeFactory); Argument.IsNotNull(() => keyboardMappingsService); Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => splashScreenService); Argument.IsNotNull(() => ensureStartupService); Argument.IsNotNull(() => applicationInitializationService); Argument.IsNotNull(() => dependencyResolver); _typeFactory = typeFactory; _keyboardMappingsService = keyboardMappingsService; _commandManager = commandManager; _splashScreenService = splashScreenService; _ensureStartupService = ensureStartupService; _applicationInitializationService = applicationInitializationService; _dependencyResolver = dependencyResolver; var entryAssembly = AssemblyHelper.GetEntryAssembly(); Log.Info("Starting {0} v{1} ({2})", entryAssembly.Title(), entryAssembly.Version(), entryAssembly.InformationalVersion()); // Initialize (now we have an application) DotNetPatchHelper.Initialize(); }
public CrashWarningViewModel(IAppDataService appDataService, IMessageService messageService, INavigationService navigationService, ILanguageService languageService) { Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => appDataService); Argument.IsNotNull(() => languageService); _appDataService = appDataService; _messageService = messageService; _navigationService = navigationService; _languageService = languageService; _assembly = AssemblyHelper.GetEntryAssembly(); Continue = new TaskCommand(OnContinueExecuteAsync); ResetUserSettings = new TaskCommand(OnResetUserSettingsExecuteAsync); BackupAndReset = new TaskCommand(OnResetAndBackupExecuteAsync); }
/// <summary> /// Creates a new shell. /// </summary> /// <typeparam name="TShell">The type of the shell.</typeparam> /// <param name="postShowShellCallback">The shell created callback.</param> /// <returns>The created shell.</returns> /// <exception cref="OrchestraException">The shell is already created and cannot be created again.</exception> private async Task <TShell> CreateShellInternalAsync <TShell>(Action postShowShellCallback = null) where TShell : IShell { if (Shell != null) { throw Log.ErrorAndCreateException <OrchestraException>("The shell is already created and cannot be created again"); } Log.Info("Checking if software was correctly closed previously"); await _ensureStartupService.EnsureFailSafeStartupAsync(); var shell = default(TShell); var successfullyStarted = true; try { await InitializeBeforeCreatingShellAsync(); shell = await CreateShellAsync <TShell>(); _keyboardMappingsService.Load(); // Now we have a new window, resubscribe the command manager _commandManager.SubscribeToKeyboardEvents(); await InitializeAfterCreatingShellAsync(); Log.Info("Confirming that application was started successfully"); _ensureStartupService.ConfirmApplicationStartedSuccessfully(); await InitializeBeforeShowingShellAsync(); ShowShell(shell); if (postShowShellCallback != null) { postShowShellCallback(); } await InitializeAfterShowingShellAsync(); } catch (Exception ex) { Log.Error(ex, "An unexpected error occurred, shutting down the application"); successfullyStarted = false; } if (!successfullyStarted) { var entryAssembly = AssemblyHelper.GetEntryAssembly(); var assemblyTitle = entryAssembly.Title(); // Late resolve so user might change the message service var messageService = _dependencyResolver.Resolve <IMessageService>(); await messageService.ShowErrorAsync(string.Format("An unexpected error occurred while starting {0}. Unfortunately it needs to be closed.\n\nPlease try restarting the application. If this error keeps coming up while starting the application, please contact support.", assemblyTitle), string.Format("Failed to start {0}", assemblyTitle)); Application.Current.Shutdown(-1); } return(shell); }