public void Add([NotNull] string rule, [NotNull] string name, [CanBeNull] string value)
        {
            Guard.NotNull(rule, nameof(rule));
            Guard.NotNull(name, nameof(name));

            var key = new AnalyzerSettingKey(rule, name);

            settings[key] = value;
        }
예제 #2
0
        private static void WriteSettingElement([NotNull] AnalyzerSettingKey settingKey, [NotNull] string settingValue,
                                                [NotNull] XmlWriter writer)
        {
            writer.WriteStartElement("setting");

            writer.WriteAttributeString("rule", settingKey.Rule);
            writer.WriteAttributeString("name", settingKey.Name);
            writer.WriteAttributeString("value", settingValue);

            writer.WriteEndElement();
        }
        internal int?TryGetInt32([NotNull] AnalyzerSettingKey key, int minValue, int maxValue)
        {
            Guard.NotNull(key, nameof(key));

            if (settings.ContainsKey(key) && int.TryParse(settings[key], out int value))
            {
                if (value < minValue || value > maxValue)
                {
                    throw new ArgumentOutOfRangeException(
                              $"Value for {key} configuration setting must be in range {minValue}-{maxValue}.", (Exception)null);
                }

                return(value);
            }

            return(null);
        }