public void ReadFromStream(TextReader sr) { PBXStream.ReadLinesWithConditionForLastLine(sr, m_Header, s => s.Trim() == "objects = {"); string line = PBXStream.ReadSkippingEmptyLines(sr); string prevSectionName = null; while (PBXRegex.BeginSection.IsMatch(line)) { string sectName = PBXRegex.BeginSection.Match(line).Groups[1].Value; // Duplicate sections (which should never appear) will be simply read again. if (m_Section.ContainsKey(sectName)) { m_Section[sectName].ReadSection(line, sr); } else { SectionBase sect = new TextSection(); sect.ReadSection(line, sr); m_Section.Add(sectName, sect); } // if the section is unknown, save its position relative to other sections if (!m_SectionOrder.Contains(sectName)) { int pos = 0; if (prevSectionName != null) // TODO: static analysis: expression is always false { pos = m_SectionOrder.FindIndex(x => x == prevSectionName); // this never fails pos += 1; } m_SectionOrder.Insert(pos, sectName); } line = PBXStream.ReadSkippingEmptyLines(sr); } m_Footer.Add(line); PBXStream.ReadLinesFromFile(sr, m_Footer); }
public override void ReadSection(string curLine, TextReader sr) { text.Add(curLine); PBXStream.ReadLinesWithConditionForLastLine(sr, text, s => PBXRegex.EndSection.IsMatch(s)); }