예제 #1
0
        /// <summary>
        /// Sets the value of the additional setting. The setting will be added if it does not already exist.
        /// </summary>
        private 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");
            }

            ConfigSetting setting;

            if (config.TryGetConfigSetting(settingId, out setting))
            {
                setting.Value = value;
            }
            else
            {
                setting = new ConfigSetting()
                {
                    Id    = settingId,
                    Value = value
                };
            }

            if (config.AdditionalConfig == null)
            {
                config.AdditionalConfig = new System.Collections.Generic.List <ConfigSetting>();
            }
            config.AdditionalConfig.Add(setting);
        }
예제 #2
0
        public static string GetSettingsFilePath(this AnalysisConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (config.TryGetConfigSetting(SettingsFileKey, out ConfigSetting setting))
            {
                return(setting.Value);
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// Returns the value of the specified config setting, or the supplied default value if the setting could not be found
        /// </summary>
        public static string GetConfigValue(this AnalysisConfig config, string settingId, string defaultValue)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrWhiteSpace(settingId))
            {
                throw new ArgumentNullException("settingId");
            }

            var result = defaultValue;

            if (config.TryGetConfigSetting(settingId, out ConfigSetting setting))
            {
                result = setting.Value;
            }

            return(result);
        }