/// <summary> /// Parse the given line as key:value pair. /// </summary> /// <param name="section">The current section, where to store the key:value pair.</param> /// <param name="line">The line that should be parsed.</param> void LoadValue(SteamConfigSection section, string line) { var pair = ExtractValueLine.Matches(line); if (pair.Count < 1) { throw new SteamConfigValueException(line); } var key = pair[0].Groups["tag"].Value; var value = pair[0].Groups["value"].Value; section[key] = new SteamConfigValue(key, value); }
/// <summary> /// Parse the whole section. /// </summary> /// <param name="reader">The <see cref="StreamReader"/> where to read from.</param> /// <param name="section">The current section, where to store all the current entries.</param> /// <param name="name">The name of the current section.</param> void LoadSection(StreamReader reader, SteamConfigSection section, string name) { // Skip everything until open bracked reached // mostly, this is found on the next line while (reader.ReadLine().Trim() != "{") { } if (section == null) { section = this.RootSection = new SteamConfigSection(name); } var line = ""; while (!reader.EndOfStream) { line = reader.ReadLine().Trim(); if (line == "}") { break; } if (MatchValueLine.IsMatch(line)) { // Line contains a key:value pair this.LoadValue(section, line); } else { // Line contains a new section var newName = line.Trim('"'); section[newName] = new SteamConfigSection(newName); this.LoadSection(reader, section[newName] as SteamConfigSection, newName); } } }