/// <summary> /// Attempts to load the session corresponding to the given path. /// </summary> /// <param name="filePath">The path to a solution or package file.</param> /// <returns><c>True</c> if the session was successfully loaded, <c>False</c> if an error occurred, <c>Null</c> if the operation was cancelled by user.</returns> public async Task <bool?> OpenSession(UFile filePath) { if (Session != null) { throw new InvalidOperationException("A session is already open in this instance."); } if (filePath != null && !File.Exists(filePath)) { MRU.RemoveFile(filePath); await ServiceProvider.Get <IDialogService>().MessageBox(string.Format(Tr._p("Message", @"The file '{0}' does not exist."), filePath), MessageBoxButton.OK, MessageBoxImage.Information); return(false); } var sessionResult = new PackageSessionResult(); var loadedSession = await SessionViewModel.OpenSession(filePath, ServiceProvider, this, sessionResult); // Loading has failed if (loadedSession == null) { // Null means the user has cancelled the loading operation. return(sessionResult.OperationCancelled ? (bool?)null : false); } MRU.AddFile(filePath); Session = loadedSession; InternalSettings.FileDialogLastOpenSessionDirectory.SetValue(new UFile(filePath).GetFullDirectory()); InternalSettings.Save(); return(true); }