public static async Task <IIniSection> ParseAsync(string name, TextReader reader, string summary = null) { var result = CreateSection(name); if (string.IsNullOrWhiteSpace(summary)) { result.Summary = summary; } while (reader.Peek() > 0) { string line = await reader.ReadLineAsync(); if (string.IsNullOrWhiteSpace(line)) { if (reader.Peek() == '[') { break; } continue; } result.Put(IniKeyValuePairUtils.Parse(line)); if (reader.Peek() == '[') { break; } } return(result); }
public static async Task <IIniDocument> ParseAsync(TextReader reader) { IniDocument document = new IniDocument(); bool readHeader = true; while (reader.Peek() > 0) { string line = await reader.ReadLineAsync(); if (string.IsNullOrWhiteSpace(line)) { continue; } if (line.TrimStart()[0].Equals('[')) { readHeader = false; } if (readHeader) { document.Head.Put(IniKeyValuePairUtils.Parse(line)); } else { document.Put(await IniSectionUtils.ParseAsync(reader, line)); } } return(document); }