protected override bool OnTryGet(SettingsHive hive, string name, out string value) { object sync = base.Sync; lock (sync) { return(this.GetHive(hive).TryGetValue(name, out value)); } }
public bool Remove(SettingsHive hive, string name) { object sync = base.Sync; lock (sync) { return(this.GetHive(hive).Remove(name)); } }
protected override bool OnTrySet(SettingsHive hive, string name, string value) { object sync = base.Sync; lock (sync) { this.GetHive(hive)[name] = value; return(true); } }
private Dictionary <string, string> GetHive(SettingsHive hive) { if (hive != SettingsHive.CurrentUser) { if (hive != SettingsHive.SystemWide) { throw new InternalErrorException(); } return(this.systemWideValues); } return(this.currentUserValues); }
private RegistrySettings GetHive(SettingsHive hive) { if (hive != SettingsHive.CurrentUser) { if (hive != SettingsHive.SystemWide) { throw ExceptionUtil.InvalidEnumArgumentException <SettingsHive>(hive, "hive"); } return(RegistrySettings.SystemWide); } return(RegistrySettings.CurrentUser); }
protected override bool OnTrySet(SettingsHive hive, string name, string value) { RegistrySettings settings = this.GetHive(hive); try { settings.SetString(name, value); return(true); } catch (Exception) { return(false); } }
protected override bool OnTryGet(SettingsHive hive, string name, out string value) { RegistrySettings settings = this.GetHive(hive); try { value = settings.GetString(name); return(value > null); } catch (Exception) { value = null; return(false); } }
private bool TryGetValue(SettingsHive hive, string path, Type valueType, SettingConverter converter, out object value) { string str; if (!this.TryGet(hive, path, out str)) { value = null; return(false); } try { value = converter.ConvertFromStorage(valueType, str); return(true); } catch (Exception) { value = null; return(false); } }
private static void GetHiveQueryOrder(SettingScope scope, out SettingsHive firstTryHive, out SettingsHive?secondTryHive) { switch (scope) { case SettingScope.CurrentUser: firstTryHive = SettingsHive.CurrentUser; break; case SettingScope.CurrentUserWithSystemWideOverride: firstTryHive = SettingsHive.SystemWide; break; case SettingScope.SystemWide: firstTryHive = SettingsHive.SystemWide; break; case SettingScope.SystemWideWithCurrentUserOverride: firstTryHive = SettingsHive.CurrentUser; break; default: throw ExceptionUtil.InvalidEnumArgumentException <SettingScope>(scope, "scope"); } switch (scope) { case SettingScope.CurrentUser: case SettingScope.SystemWide: secondTryHive = 0; return; case SettingScope.CurrentUserWithSystemWideOverride: secondTryHive = 0; return; case SettingScope.SystemWideWithCurrentUserOverride: secondTryHive = 1; return; } throw ExceptionUtil.InvalidEnumArgumentException <SettingScope>(scope, "scope"); }
public bool TryGet(SettingsHive hive, string path, out string storageValue) => this.OnTryGet(hive, path, out storageValue);
protected abstract bool OnTrySet(SettingsHive hive, string name, string value);
protected abstract bool OnTryGet(SettingsHive hive, string path, out string storageValue);
public bool UnsafeTrySet(SettingsHive hive, string name, string value) => this.OnTrySet(hive, name, value);
protected override bool OnTrySet(SettingsHive hive, string name, string value) => false;
protected override bool OnTryGet(SettingsHive hive, string name, out string value) { value = null; return(false); }