예제 #1
0
        internal void Read(TextReader reader, string line, ref int curLineNum)
        {
            Line = curLineNum;

            int n = 0;

            FindNext(curLineNum, line, ref n, '(');
            n++;
            FindNext(curLineNum, line, ref n, '"');
            int n2 = n + 1;

            FindNext(curLineNum, line, ref n2, '"');
            TypeGuid = line.Substring(n + 1, n2 - n - 1);

            n = n2 + 1;
            FindNext(curLineNum, line, ref n, ')');
            FindNext(curLineNum, line, ref n, '=');

            FindNext(curLineNum, line, ref n, '"');
            n2 = n + 1;
            FindNext(curLineNum, line, ref n2, '"');
            Name = line.Substring(n + 1, n2 - n - 1);

            n = n2 + 1;
            FindNext(curLineNum, line, ref n, ',');
            FindNext(curLineNum, line, ref n, '"');
            n2 = n + 1;
            FindNext(curLineNum, line, ref n2, '"');
            FilePath = line.Substring(n + 1, n2 - n - 1);

            n = n2 + 1;
            FindNext(curLineNum, line, ref n, ',');
            FindNext(curLineNum, line, ref n, '"');
            n2 = n + 1;
            FindNext(curLineNum, line, ref n2, '"');
            Id = line.Substring(n + 1, n2 - n - 1);

            while ((line = reader.ReadLine()) != null)
            {
                curLineNum++;
                line = line.Trim();
                if (line == "EndProject")
                {
                    return;
                }
                if (line.StartsWith("ProjectSection", StringComparison.Ordinal))
                {
                    if (_sections == null)
                    {
                        _sections = new SlnSectionCollection();
                    }
                    var sec = new SlnSection();
                    _sections.Add(sec);
                    sec.Read(reader, line, ref curLineNum);
                }
            }

            throw new InvalidSolutionFormatException(curLineNum, LocalizableStrings.ProjectSectionNotClosedError);
        }
예제 #2
0
        private void Read(TextReader reader)
        {
            const string HeaderPrefix = "Microsoft Visual Studio Solution File, Format Version";

            string line;
            int    curLineNum  = 0;
            bool   globalFound = false;
            bool   productRead = false;

            while ((line = reader.ReadLine()) != null)
            {
                curLineNum++;
                line = line.Trim();
                if (line.StartsWith(HeaderPrefix, StringComparison.Ordinal))
                {
                    if (line.Length <= HeaderPrefix.Length)
                    {
                        throw new InvalidSolutionFormatException(
                                  curLineNum,
                                  LocalizableStrings.FileHeaderMissingVersionError);
                    }

                    FormatVersion     = line.Substring(HeaderPrefix.Length).Trim();
                    _prefixBlankLines = curLineNum - 1;
                }
                if (line.StartsWith("# ", StringComparison.Ordinal))
                {
                    if (!productRead)
                    {
                        productRead        = true;
                        ProductDescription = line.Substring(2);
                    }
                }
                else if (line.StartsWith("Project", StringComparison.Ordinal))
                {
                    SlnProject p = new SlnProject();
                    p.Read(reader, line, ref curLineNum);
                    _projects.Add(p);
                }
                else if (line == "Global")
                {
                    if (globalFound)
                    {
                        throw new InvalidSolutionFormatException(
                                  curLineNum,
                                  LocalizableStrings.GlobalSectionMoreThanOnceError);
                    }
                    globalFound = true;
                    while ((line = reader.ReadLine()) != null)
                    {
                        curLineNum++;
                        line = line.Trim();
                        if (line == "EndGlobal")
                        {
                            break;
                        }
                        else if (line.StartsWith("GlobalSection", StringComparison.Ordinal))
                        {
                            var sec = new SlnSection();
                            sec.Read(reader, line, ref curLineNum);
                            _sections.Add(sec);
                        }
                        else // Ignore text that's out of place
                        {
                            continue;
                        }
                    }
                    if (line == null)
                    {
                        throw new InvalidSolutionFormatException(
                                  curLineNum,
                                  LocalizableStrings.GlobalSectionNotClosedError);
                    }
                }
                else if (line.IndexOf('=') != -1)
                {
                    _metadata.ReadLine(line, curLineNum);
                }
            }
            if (FormatVersion == null)
            {
                throw new InvalidSolutionFormatException(LocalizableStrings.FileHeaderMissingError);
            }
        }
예제 #3
0
 internal SlnPropertySetCollection(SlnSection parentSection)
 {
     _parentSection = parentSection;
 }
예제 #4
0
        public void Read(TextReader reader)
        {
            string line;
            int    curLineNum  = 0;
            bool   globalFound = false;
            bool   productRead = false;

            while ((line = reader.ReadLine()) != null)
            {
                curLineNum++;
                line = line.Trim();
                if (line.StartsWith("Microsoft Visual Studio Solution File", StringComparison.Ordinal))
                {
                    int i = line.LastIndexOf(' ');
                    if (i == -1)
                    {
                        throw new InvalidSolutionFormatException(curLineNum);
                    }
                    FormatVersion    = line.Substring(i + 1);
                    prefixBlankLines = curLineNum - 1;
                }
                if (line.StartsWith("# ", StringComparison.Ordinal))
                {
                    if (!productRead)
                    {
                        productRead        = true;
                        ProductDescription = line.Substring(2);
                    }
                }
                else if (line.StartsWith("Project", StringComparison.Ordinal))
                {
                    SlnProject p = new SlnProject();
                    p.Read(reader, line, ref curLineNum);
                    projects.Add(p);
                }
                else if (line == "Global")
                {
                    if (globalFound)
                    {
                        throw new InvalidSolutionFormatException(curLineNum, "Global section specified more than once");
                    }
                    globalFound = true;
                    while ((line = reader.ReadLine()) != null)
                    {
                        curLineNum++;
                        line = line.Trim();
                        if (line == "EndGlobal")
                        {
                            break;
                        }
                        else if (line.StartsWith("GlobalSection", StringComparison.Ordinal))
                        {
                            var sec = new SlnSection();
                            sec.Read(reader, line, ref curLineNum);
                            sections.Add(sec);
                        }
                        else // Ignore text that's out of place
                        {
                            continue;
                        }
                    }
                    if (line == null)
                    {
                        throw new InvalidSolutionFormatException(curLineNum, "Global section not closed");
                    }
                }
                else if (line.IndexOf('=') != -1)
                {
                    metadata.ReadLine(line, curLineNum);
                }
            }
            if (FormatVersion == null)
            {
                throw new InvalidSolutionFormatException(curLineNum, "File header is missing");
            }
        }