Beispiel #1
0
        internal static SectionBlock Parse(TextReader reader)
        {
            string startLine;

            while ((startLine = reader.ReadLine()) != null)
            {
                startLine = startLine.TrimStart(null);
                if (startLine != string.Empty)
                {
                    break;
                }
            }

            LineScanner scanner = new LineScanner(startLine);

            string type = scanner.ReadUpToAndEat("(");
            string parenthesizedName = scanner.ReadUpToAndEat(") = ");
            string sectionValue      = scanner.ReadRest();

            List <SolutionProperty> properties = new List <SolutionProperty>();
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                line = line.TrimStart(null);

                // ignore empty lines
                if (line == string.Empty)
                {
                    continue;
                }

                if (line == "End" + type)
                {
                    break;
                }

                scanner = new LineScanner(line);
                string key   = scanner.ReadUpToAndEat(" = ");
                string value = scanner.ReadRest();

                properties.Add(new SolutionProperty(key, value));
            }

            return(new SectionBlock(type, parenthesizedName, sectionValue, properties));
        }
        internal static ProjectBlock Parse(TextReader reader)
        {
            string      startLine = reader.ReadLine().TrimStart(null);
            LineScanner scanner   = new LineScanner(startLine);

            if (scanner.ReadUpToAndEat("(\"") != "Project")
            {
                throw new Exception();
            }

            Guid projectTypeGuid = Guid.Parse(scanner.ReadUpToAndEat("\")"));

            // Read chars up to next quote, must contain "=" with optional leading/trailing whitespaces.
            if (scanner.ReadUpToAndEat("\"").Trim() != "=")
            {
                throw new Exception();
            }

            string projectName = scanner.ReadUpToAndEat("\"");

            // Read chars up to next quote, must contain "," with optional leading/trailing whitespaces.
            if (scanner.ReadUpToAndEat("\"").Trim() != ",")
            {
                throw new Exception();
            }

            string projectPath = scanner.ReadUpToAndEat("\"");

            // Read chars up to next quote, must contain "," with optional leading/trailing whitespaces.
            if (scanner.ReadUpToAndEat("\"").Trim() != ",")
            {
                throw new Exception();
            }

            Guid projectGuid = Guid.Parse(scanner.ReadUpToAndEat("\""));

            List <SectionBlock> projectSections = new List <SectionBlock>();

            while (char.IsWhiteSpace((char)reader.Peek()))
            {
                projectSections.Add(SectionBlock.Parse(reader));
            }

            // Expect to see "EndProject" but be tolerant with missing tags as in Dev12.
            // Instead, we may see either P' for "Project" or 'G' for "Global", which will be handled next.
            if (reader.Peek() != 'P' && reader.Peek() != 'G')
            {
                if (reader.ReadLine() != "EndProject")
                {
                    throw new Exception();
                }
            }

            return(new ProjectBlock(projectTypeGuid, projectName, projectPath, projectGuid, projectSections));
        }