private static void ParseNested(TextData parent, TextReader source) { string line = null; TextData current = null; do { line = source.ReadLine().Trim(); if (line.Length > 0) { if (line[0] == '{') { if (current == null) current = new TextData(); ParseNested(current, source); } else if (line[0] == '}') { return; } else { current = new TextData(); current.ParseLine(line); } } if (current != null) parent.Nested[current.Name] = current; } while (line != null); }
public static TextData Parse(TextReader source) { string prevLine = null; string startLine = source.ReadLine().Trim(); while (startLine[0] != '{') { prevLine = startLine; startLine = source.ReadLine().Trim(); } TextData startParent = new TextData(); if (prevLine != null) startParent.ParseLine(prevLine); ParseNested(startParent, source); return startParent; }