async Task RestoreWorkspacePreferences (WorkspaceItem item) { // Restore local configuration data try { WorkspaceUserData data = item.UserProperties.GetValue<WorkspaceUserData> ("MonoDevelop.Ide.Workspace"); if (data != null) { ActiveExecutionTarget = null; if (GetConfigurations ().Contains (data.ActiveConfiguration)) activeConfiguration = data.ActiveConfiguration; else activeConfiguration = GetBestDefaultConfiguration (); if (string.IsNullOrEmpty (data.ActiveRuntime)) UseDefaultRuntime = true; else { TargetRuntime tr = Runtime.SystemAssemblyService.GetTargetRuntime (data.ActiveRuntime); if (tr != null) ActiveRuntime = tr; else UseDefaultRuntime = true; } OnActiveConfigurationChanged (); } else { ActiveConfigurationId = GetBestDefaultConfiguration (); } } catch (Exception ex) { LoggingService.LogError ("Exception while loading user solution preferences.", ex); } // Allow add-ins to restore preferences if (LoadingUserPreferences != null) { UserPreferencesEventArgs args = new UserPreferencesEventArgs (item, item.UserProperties); try { foreach (AsyncEventHandler<UserPreferencesEventArgs> d in LoadingUserPreferences.GetInvocationList ()) await d (this, args); } catch (Exception ex) { LoggingService.LogError ("Exception in LoadingUserPreferences.", ex); } } }
public Task SavePreferences (WorkspaceItem item) { // Local configuration info WorkspaceUserData data = new WorkspaceUserData (); data.ActiveConfiguration = ActiveConfigurationId; data.ActiveRuntime = UseDefaultRuntime ? null : ActiveRuntime.Id; item.UserProperties.SetValue ("MonoDevelop.Ide.Workspace", data); // Allow add-ins to fill-up data if (StoringUserPreferences != null) { UserPreferencesEventArgs args = new UserPreferencesEventArgs (item, item.UserProperties); try { StoringUserPreferences (this, args); } catch (Exception ex) { LoggingService.LogError ("Exception in UserPreferencesRequested.", ex); } } // Save the file return item.SaveUserProperties (); }