Пример #1
0
        public string GetSetting(string key)
        {
            SettingsProperty property = GetProperty(key);

            if (property is SingleSettingsProperty single)
            {
                return(single.Value);
            }

            CollectionSettingsProperty collection = (CollectionSettingsProperty)property;

            return(string.Join(";", collection.Values));
        }
Пример #2
0
        public void ClearSetting(string key)
        {
            SettingsProperty property = GetProperty(key);

            if (property is SingleSettingsProperty single)
            {
                single.Value = string.Empty;
            }
            else
            {
                CollectionSettingsProperty collection = (CollectionSettingsProperty)property;
                collection.Values.Clear();
            }
        }
Пример #3
0
        public void SetSetting(string key, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new SettingValueIsEmptyException();
            }
            SettingsProperty property = GetProperty(key);

            if (property is SingleSettingsProperty single)
            {
                single.Value = value;
            }
            else
            {
                CollectionSettingsProperty collection = (CollectionSettingsProperty)property;
                collection.Values.Clear();
                collection.Values.AddRange(value.Split(new[] { Constants.SettingSplitChar }, StringSplitOptions.RemoveEmptyEntries)
                                           .Distinct());
            }
        }