public bool CommitSettings() { lock (ProfileManager.dataLock) { if (ProfileManager.backupCount == 0) { return(false); } if (ProfileManager.backupCount > 1) { ProfileManager.backupCount--; return(false); } ProfileManager.backupSettings = null; ProfileManager.backupCount = 0; RemarkerService service = this.Service; if (service == null) { return(false); } service.OnSettingsChanged(); return(true); } }
public void SaveSettingsToStorage(RemarkerService service) { Contract.Requires(service != null); lock (ProfileManager.dataLock) { if (ProfileManager.backupSettings != null) { return; } } RegistryKey key = null; try { key = service.Package.UserRegistryRoot.CreateSubKey(ProfileManager.SUBKEY_NAME); Debug.Assert(key != null, "key != null"); key.SetValue("Version", service.Version); foreach (var valueName in service.ValueNames) { service.Save(key, valueName); } } finally { if (key != null) { key.Close(); } } }
public bool RollBackSettings() { lock (ProfileManager.dataLock) { if (ProfileManager.backupCount == 0) { return(false); } if (ProfileManager.backupSettings == null) { ProfileManager.backupCount--; return(false); } RemarkerService service = this.Service; foreach (var backupSetting in ProfileManager.backupSettings) { // Restore the original setting service.Load(backupSetting.Value, backupSetting.Key); } return(true); } }
public void ResetSettings(RemarkerService service) { Contract.Requires(service != null); service.Package.UserRegistryRoot.DeleteSubKey(ProfileManager.SUBKEY_NAME, false); this.LoadSettingsFromStorage(this.Service); }
public void SaveSettingsToXml(IVsSettingsWriter writer) { RemarkerService service = this.Service; var stringBuilder = new StringBuilder(); foreach (var valueName in service.ValueNames) { stringBuilder.Append(valueName); stringBuilder.Append(";"); service.Save(writer, valueName); } writer.WriteSettingLong("Version", service.Version); writer.WriteSettingString("ValueKeys", stringBuilder.ToString()); }
public void LoadSettingsFromXml(IVsSettingsReader reader) { string valueKeysString; reader.ReadSettingString("ValueKeys", out valueKeysString); RemarkerService service = this.Service; foreach (var valueKey in valueKeysString.Split(';').Where( valueKey => !string.IsNullOrWhiteSpace(valueKey))) { try { service.Load(reader, valueKey); } catch (Exception) { } } }
public bool ProtectSettings() { lock (ProfileManager.dataLock) { if (ProfileManager.backupSettings != null) { ProfileManager.backupCount++; return(false); } RemarkerService service = this.Service; ProfileManager.backupSettings = new Dictionary <string, string>(); foreach (var valueName in service.ValueNames) { ProfileManager.backupSettings.Add(valueName, service.ReadValue(valueName)); } ProfileManager.backupCount = 1; return(true); } }
public void LoadSettingsFromStorage(RemarkerService service) { Contract.Requires(service != null); lock (ProfileManager.dataLock) { if (ProfileManager.backupSettings != null) { return; } } RegistryKey key = null; try { key = service.Package.UserRegistryRoot.OpenSubKey(ProfileManager.SUBKEY_NAME); foreach (var valueName in service.ValueNames) { service.Load(key, valueName); } } catch (Exception ex) { Trace.WriteLine(string.Format("Remarker::LoadSettingsFromStorage: {0}", ex)); } finally { if (key != null) { key.Close(); } } }