public void Save() { SettingsCache.Save(); if (LowerPriority != null) { LowerPriority.Save(); } }
/// <summary> /// sets given value at the possible lowest priority level /// </summary> public override void SetValue <T>(string name, T value, Func <T, string> encode) { if (LowerPriority == null || SettingsCache.HasValue(name)) { SettingsCache.SetValue(name, value, encode); } else { LowerPriority.SetValue(name, value, encode); } }
public virtual bool TryGetValue <T>(string name, T defaultValue, Func <string, T> decode, out T value) { if (SettingsCache.TryGetValue <T>(name, defaultValue, decode, out value)) { return(true); } if (LowerPriority != null && LowerPriority.TryGetValue(name, defaultValue, decode, out value)) { return(true); } return(false); }
public void LockedAction(Action action) { SettingsCache.LockedAction(() => { if (LowerPriority != null) { LowerPriority.LockedAction(action); } else { action(); } }); }
public override void SetValue <T>(string name, T value, Func <T, string> encode) { //Settings stored in Distributed always have to be set directly if (LowerPriority == null || LowerPriority.LowerPriority == null || SettingsCache.HasValue(name)) { SettingsCache.SetValue(name, value, encode); } else if (LowerPriority.SettingsCache.HasValue(name)) { LowerPriority.SetValue(name, value, encode); } else { LowerPriority.LowerPriority.SetValue(name, value, encode); } }
public override void SetValue <T>(string name, T value, Func <T, string> encode) { bool isEffectiveLevel = LowerPriority?.LowerPriority is not null; bool isDetachedOrGlobal = LowerPriority is null; if (isDetachedOrGlobal || SettingsCache.HasValue(name)) { // there is no lower level // or the setting is assigned on this level SettingsCache.SetValue(name, value, encode); } else if (isEffectiveLevel) { // Settings stored at the Distributed level always have to be set directly // so I do not pass the control to the LowerPriority(Distributed) // in order to not overwrite the setting if (LowerPriority.SettingsCache.HasValue(name)) { // if the setting is set at the Distributed level, do not overwrite it // instead of that, set the setting at the Local level to make it effective // but only if the effective value is different from the new value if (LowerPriority.SettingsCache.HasADifferentValue(name, value, encode)) { SettingsCache.SetValue(name, value, encode); } } else { // if the setting isn't set at the Distributed level, do not set it there // instead of that, set the setting at the Global level (it becomes effective then) LowerPriority.LowerPriority.SetValue(name, value, encode); } } else { // the settings is not assigned on this level, recurse to the lower level LowerPriority.SetValue(name, value, encode); } }
public void Save() { SettingsCache.Save(); LowerPriority?.Save(); }
public void Save() { _credentialsManager.Save(); SettingsCache.Save(); LowerPriority?.Save(); }