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)); }
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(); } }
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()); } }