Exemplo n.º 1
0
        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);
                }
            }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        public override void SetValue(string name, string?value)
        {
            // For the effective level read the effective value explicitly
            // as the SetValue below just check the explicit level
            if (SettingLevel == SettingLevel.Effective && value == GetValue(name))
            {
                return;
            }

            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);
            }
            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))
                    {
                        SettingsCache.SetValue(name, value);
                    }
                }
                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);
                }
            }