/// <summary>Sets the values of settings.</summary>
        public override async Task <bool> Set(SettingGroup settingGroup, Values values)
        {
            bool success = true;

            foreach ((Setting? setting, object?value) in values)
            {
                success = await this.Set(setting, value) && success;
            }

            return(success);
        }
Exemplo n.º 2
0
        public virtual void Deserialized(SettingGroup settingGroup, string settingId)
        {
            this.SettingGroup = settingGroup;
            this.Id           = settingId;
            if (string.IsNullOrEmpty(this.Name))
            {
                this.Name = this.Id;
            }

            this.Range?.Deserialized(this);
        }
        /// <summary>Gets the values of the given settings.</summary>
        public override async Task <Values> Get(SettingGroup settingGroup, IEnumerable <Setting> settings)
        {
            Values values = new Values();

            foreach (Setting setting in settings)
            {
                object?value = await this.Get(setting);

                if (!(value is NoValue))
                {
                    values.Add(setting, value);
                }
            }

            return(values);
        }
Exemplo n.º 4
0
        public virtual void Deserialized(SettingGroup settingGroup, string settingId)
        {
            this.SettingGroup = settingGroup;
            this.Id           = settingId;
            if (string.IsNullOrEmpty(this.Name))
            {
                this.Name = this.Id;
            }

            if (this.extraPropertiesJson is not null)
            {
                this.extraProperties     = this.extraPropertiesJson.ToDictionary(kv => kv.Key, kv => kv.Value.ToString());
                this.extraPropertiesJson = null;
            }

            this.Range?.Deserialized(this);
        }
Exemplo n.º 5
0
 /// <summary>Gets the value of all settings in a group.</summary>
 public virtual Task <Values> Get(SettingGroup settingGroup)
 {
     return(this.Get(settingGroup, settingGroup));
 }
Exemplo n.º 6
0
 /// <summary>Sets the given values to setting in a group.</summary>
 public abstract Task <bool> Set(SettingGroup settingGroup, Values values);
Exemplo n.º 7
0
 /// <summary>Gets the value of the specified settings of a group.</summary>
 public abstract Task <Values> Get(SettingGroup settingGroup, IEnumerable <Setting> settings);
 /// <summary>Gets the value of all settings in a group.</summary>
 // NOTE: we return both success/failure and a list of results so that we can return partial results in case of partial failure
 public virtual async Task <(MorphicResult <MorphicUnit, MorphicUnit>, Values)> GetAsync(SettingGroup settingGroup)
 {
     return(await this.GetAsync(settingGroup, settingGroup));
 }
 /// <summary>Sets the given values to setting in a group.</summary>
 public abstract Task <MorphicResult <MorphicUnit, MorphicUnit> > SetAsync(SettingGroup settingGroup, Values values);
 /// <summary>Gets the value of the specified settings of a group.</summary>
 // NOTE: we return both success/failure and a list of results so that we can return partial results in case of partial failure
 public abstract Task <(MorphicResult <MorphicUnit, MorphicUnit>, Values)> GetAsync(SettingGroup settingGroup, IEnumerable <Setting> settings);
Exemplo n.º 11
0
        /// <summary>Gets the values of the given settings.</summary>
        // NOTE: we return both success/failure and a list of results so that we can return partial results in case of partial failure
        public override async Task <(MorphicResult <MorphicUnit, MorphicUnit>, Values)> GetAsync(SettingGroup settingGroup, IEnumerable <Setting> settings)
        {
            var success = true;

            Values values = new Values();

            foreach (Setting setting in settings)
            {
                object?value;
                var    getResult = await this.GetAsync(setting);

                if (getResult.IsSuccess == true)
                {
                    value = getResult.Value;

                    if (!(value is NoValue))
                    {
                        values.Add(setting, value);
                    }
                }
                else
                {
                    success = false;
                    // not captured; skip to the next setting
                    continue;
                }
            }

            return((success ? MorphicResult.OkResult() : MorphicResult.ErrorResult()), values);
        }
Exemplo n.º 12
0
        /// <summary>Sets the values of settings.</summary>
        public override async Task <MorphicResult <MorphicUnit, MorphicUnit> > SetAsync(SettingGroup settingGroup, Values values)
        {
            bool success = true;

            foreach ((Setting? setting, object?value) in values)
            {
                var settingSetResult = await this.SetAsync(setting, value);

                success = success && settingSetResult.IsSuccess;
            }

            return(success ? MorphicResult.OkResult() : MorphicResult.ErrorResult());
        }