/// <summary> /// Sets the value of the additional setting. The setting will be added if it does not already exist. /// </summary> public static void SetValue(this AnalysisConfig config, string settingId, string value) { if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrWhiteSpace(settingId)) { throw new ArgumentNullException("settingId"); } AnalysisSetting setting; if (config.TryGetSetting(settingId, out setting)) { setting.Value = value; } else { setting = new AnalysisSetting() { Id = settingId, Value = value }; } if (config.AdditionalSettings == null) { config.AdditionalSettings = new System.Collections.Generic.List <AnalysisSetting>(); } config.AdditionalSettings.Add(setting); }
/// <summary> /// Returns the value of the specified setting, or the supplied default value if the setting could not be found /// </summary> public static string GetSetting(this AnalysisConfig config, string settingId, string defaultValue) { if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrWhiteSpace(settingId)) { throw new ArgumentNullException("settingId"); } string result = defaultValue; AnalysisSetting setting; if (config.TryGetSetting(settingId, out setting)) { result = setting.Value; } return(result); }