예제 #1
0
        public override void Parse(VSSolutionFileParser parser)
        {
            string line = parser.NextLine().Trim();
            if (line == "EndProject")
                return;

            if (line != "ProjectSection(SolutionItems) = preProject")
                parser.ThrowParserException("Unexpected token. 'ProjectSection' expected.");

            while (true)
            {
                line = parser.NextLine().Trim();
                if (line == "EndProjectSection")
                    break;

                string[] splits = line.Split('=');
                if (splits.Length != 2)
                    parser.ThrowParserException("Unexpected token.");

                files.Add(splits[0].Trim());
            }

            line = parser.NextLine().Trim();
            if (line != "EndProject")
                parser.ThrowParserException("'EndProject' expected.");
        }
예제 #2
0
        public override void Parse(VSSolutionFileParser parser)
        {
            while (true)
            {
                string line = parser.NextLine();

                if (line == null)
                    parser.ThrowParserException("Unexpected end of solution file.");

                Match endProjectMatch = VSSolution.RegexEndProject.Match(line);

                if (endProjectMatch.Success)
                    break;
            }
        }
예제 #3
0
        public override void Parse(VSSolutionFileParser parser)
        {
            while (true)
            {
                string line = parser.NextLine();

                if (line == null)
                {
                    parser.ThrowParserException("Unexpected end of solution file.");
                }

                Match endProjectMatch = VSSolution.RegexEndProject.Match(line);

                if (endProjectMatch.Success)
                {
                    break;
                }
            }
        }
예제 #4
0
        public override void Parse(VSSolutionFileParser parser)
        {
            string line = parser.NextLine().Trim();

            if (line == "EndProject")
            {
                return;
            }

            if (line != "ProjectSection(SolutionItems) = preProject")
            {
                parser.ThrowParserException("Unexpected token. 'ProjectSection' expected.");
            }

            while (true)
            {
                line = parser.NextLine().Trim();
                if (line == "EndProjectSection")
                {
                    break;
                }

                string[] splits = line.Split('=');
                if (splits.Length != 2)
                {
                    parser.ThrowParserException("Unexpected token.");
                }

                files.Add(splits[0].Trim());
            }

            line = parser.NextLine().Trim();
            if (line != "EndProject")
            {
                parser.ThrowParserException("'EndProject' expected.");
            }
        }
예제 #5
0
        public static VSSolution Load(string fileName)
        {
            //Log.DebugFormat("Load ('{0}')", fileName);

            VSSolution solution = new VSSolution(fileName);

            using (Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    VSSolutionFileParser parser = new VSSolutionFileParser(reader);

                    string line = parser.NextLine();

                    Match solutionMatch = RegexSolutionVersion.Match(line);

                    if (solutionMatch.Success == false)
                    {
                        parser.ThrowParserException("Not a solution file.");
                    }

                    solution.solutionVersion = decimal.Parse(
                        solutionMatch.Groups["version"].Value,
                        CultureInfo.InvariantCulture);

                    while (true)
                    {
                        try
                        {
                            line = parser.NextLine();

                            if (line == null)
                            {
                                break;
                            }

                            //salimos del loop cuando 'Global' aparece
                            Match globalMatch = RegexGlobal.Match(line);
                            if (globalMatch.Success)
                            {
                                break;
                            }

                            Match projectMatch = RegexProject.Match(line);

                            if (projectMatch.Success == false)
                            {
                                parser.ThrowParserException(
                                    String.Format(
                                        CultureInfo.InvariantCulture,
                                        "Could not parse solution file (line {0}).",
                                        parser.LineCount));
                            }

                            Guid   projectGuid     = new Guid(projectMatch.Groups["projectGuid"].Value);
                            string projectName     = projectMatch.Groups["name"].Value;
                            string projectFileName = projectMatch.Groups["path"].Value;
                            Guid   projectTypeGuid = new Guid(projectMatch.Groups["projectTypeGuid"].Value);

                            if (projectFileName.ToLower().Contains("http://"))
                            {
                                string path = System.IO.Path.GetDirectoryName(fileName);
                                Uri    r    = new Uri(projectFileName);
                                string f    = "";
                                f    = r.Segments[r.Segments.Length - 1];
                                path = System.IO.Directory.GetParent(path).FullName;
                                string[] files = System.IO.Directory.GetFiles(path, f, SearchOption.AllDirectories);
                                if (files != null && files.Length > 0)
                                {
                                    projectFileName = files[files.Length - 1];
                                }
                            }
                            try
                            {
                                VSProjectInfo project;
                                if (projectTypeGuid == VSProjectType.SolutionFolderProjectType.ProjectTypeGuid)
                                {
                                    project = new VSSolutionFilesInfo(
                                        solution,
                                        projectGuid,
                                        projectName,
                                        projectTypeGuid);
                                }
                                else
                                {
                                    project = new VSProjectWithFileInfo(
                                        solution,
                                        projectGuid,
                                        projectName,
                                        projectFileName,
                                        projectTypeGuid);
                                }
                                project.Parse(parser);
                                solution.projects.Add(project);
                            }
                            catch (Exception ex)
                            {
                                //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular
                            }
                        }
                        catch (Exception ex)
                        {
                            //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular
                        }
                    }
                }
            }

            return(solution);
        }
예제 #6
0
        public static VSSolution Load(string fileName)
        {
            //Log.DebugFormat("Load ('{0}')", fileName);

            VSSolution solution = new VSSolution(fileName);

            using (Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    VSSolutionFileParser parser = new VSSolutionFileParser(reader);

                    string line = parser.NextLine();

                    Match solutionMatch = RegexSolutionVersion.Match(line);

                    if (solutionMatch.Success == false)
                        parser.ThrowParserException("Not a solution file.");

                    solution.solutionVersion = decimal.Parse(
                        solutionMatch.Groups["version"].Value,
                        CultureInfo.InvariantCulture);

                    while (true)
                    {
                        try
                        {
                            line = parser.NextLine();

                            if (line == null)
                                break;

                            //salimos del loop cuando 'Global' aparece
                            Match globalMatch = RegexGlobal.Match(line);
                            if (globalMatch.Success)
                                break;

                            Match projectMatch = RegexProject.Match(line);

                            if (projectMatch.Success == false)
                                parser.ThrowParserException(
                                    String.Format(
                                        CultureInfo.InvariantCulture,
                                        "Could not parse solution file (line {0}).",
                                        parser.LineCount));

                            Guid projectGuid = new Guid(projectMatch.Groups["projectGuid"].Value);
                            string projectName = projectMatch.Groups["name"].Value;
                            string projectFileName = projectMatch.Groups["path"].Value;
                            Guid projectTypeGuid = new Guid(projectMatch.Groups["projectTypeGuid"].Value);

                            if (projectFileName.ToLower().Contains("http://"))
                            {
                                string path = System.IO.Path.GetDirectoryName(fileName);
                                Uri r = new Uri(projectFileName);
                                string f = "";
                                f = r.Segments[r.Segments.Length - 1];
                                path = System.IO.Directory.GetParent(path).FullName;
                                string[] files = System.IO.Directory.GetFiles(path, f, SearchOption.AllDirectories);
                                if (files != null && files.Length > 0)
                                {
                                    projectFileName = files[files.Length - 1];
                                }
                            }
                            try
                            {
                                VSProjectInfo project;
                                if (projectTypeGuid == VSProjectType.SolutionFolderProjectType.ProjectTypeGuid)
                                {
                                    project = new VSSolutionFilesInfo(
                                        solution,
                                        projectGuid,
                                        projectName,
                                        projectTypeGuid);
                                }
                                else
                                {
                                    project = new VSProjectWithFileInfo(
                                        solution,
                                        projectGuid,
                                        projectName,
                                        projectFileName,
                                        projectTypeGuid);
                                }
                                project.Parse(parser);
                                solution.projects.Add(project);

                            }
                            catch (Exception ex)
                            {
                                //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular
                            }
                        }
                        catch (Exception ex)
                        {
                            //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular
                        }
                    }
                }
            }

            return solution;
        }
예제 #7
0
 public abstract void Parse(VSSolutionFileParser parser);
예제 #8
0
 public abstract void Parse(VSSolutionFileParser parser);