/// <summary> /// Retrieves the setting value from this instance's current values. /// </summary> /// <param name="name">The name of the setting.</param> /// <returns>The value of the setting, or an empty string if the setting name is not found.</returns> public string GetValue(string name) { SettingValue settingValue = _values.FirstOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (settingValue != null) { return(settingValue.Value); } return(""); }
/// <summary> /// Sets the setting value. /// </summary> /// <param name="name">The name of the setting.</param> /// <param name="value">The value of the setting.</param> /// <param name="formType">The UI type that should be used to represent the value (not currently implemented).</param> public void SetValue(string name, string value, SettingFormType formType = SettingFormType.Textbox) { SettingValue settingValue = _values.FirstOrDefault(x => !string.IsNullOrEmpty(x.Name) && x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (settingValue == null) { settingValue = new SettingValue(); settingValue.Name = name; _values.Add(settingValue); } settingValue.Value = value; settingValue.FormType = formType; }
/// <summary> /// Sets the setting value. /// </summary> /// <param name="name">The name of the setting.</param> /// <param name="value">The value of the setting.</param> /// <param name="formType">The UI type that should be used to represent the value (not currently implemented).</param> public void SetValue(string name, string value, SettingFormType formType = SettingFormType.Textbox) { SettingValue settingValue = _values.FirstOrDefault(x => !string.IsNullOrEmpty(x.Name) && x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (settingValue == null) { settingValue = new SettingValue(); settingValue.Name = name; _values.Add(settingValue); } // Set form type first, so that the validation happens // Though the after-the-fact validation will work even // if done other way around. settingValue.FormType = formType; settingValue.Value = value; }