Beispiel #1
0
        private ConfigSection FindOrCreateConfigSection(string name)
        {
            var result = FindConfigSection(name);
            if (result == null)
            {
                result = new ConfigSection(name, true);
                _sections.Add(result);
            }

            return result;
        }
Beispiel #2
0
        private void FindSections(IEnumerable<string> fileLines)
        {
            ConfigSection configSection = null;

            foreach (var line in fileLines)
            {
                var m = RegParseIsSection.Match(line);
                if (m.Success) //this line is a section
                {
                    var name = m.Groups["SectionName"].Value;

                    configSection = new ConfigSection(name, false);
                    _sections.Add(configSection);
                }
                else
                {
                    m = RegParseIsKey.Match(line);
                    if (m.Success) //this line is a key
                    {
                        var key = m.Groups["Key"].Value;
                        var value = m.Groups["Value"].Value;

                        if (configSection == null)
                            throw new ConfigException(
                                string.Format("Key {0} in configfile {1} is not in a section.", key, _fileName));

                        configSection.AddValue(key, value);
                    }
                }
            }
        }
Beispiel #3
0
        private ConfigSection FindConfigSection(string name)
        {
            var configSectionToFind = new ConfigSection(name, true);

            foreach (var configSection in _sections)
            {
                if (configSectionToFind.Equals(configSection))
                    return configSection;
            }
            return null;
        }
Beispiel #4
0
 public string GetPathValue(string setting)
 {
     return(ConfigSection.UnescapeString(GetStringValue(setting)));
 }
Beispiel #5
0
 public void AddPathValue(string setting, string value)
 {
     AddStringValue(setting, ConfigSection.EscapeString(value));
 }
Beispiel #6
0
 public void SetPathValue(string setting, string value)
 {
     SetStringValue(setting, ConfigSection.EscapeString(value));
 }
Beispiel #7
0
        public bool Equals(ConfigSection other)
        {
            StringComparison sc;
            if (SubSectionCaseSensitive)
                sc = StringComparison.Ordinal;
            else
                sc = StringComparison.OrdinalIgnoreCase;

            return string.Equals(SectionName, other.SectionName, StringComparison.OrdinalIgnoreCase) &&
                string.Equals(SubSection, other.SubSection, sc);
        }