コード例 #1
0
        public static IList <ProjectModel> GetProjects(SolutionParser solution, string solutionPath)
        {
            var projects = new List <ProjectModel>();

            foreach (var proj in solution.Projects)
            {
                var xmldoc = new XmlDocument();
                try
                {
                    xmldoc.Load(Path.Combine(solutionPath, proj.RelativePath));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                var mgr = new XmlNamespaceManager(xmldoc.NameTable);
                mgr.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");

                var elemList = xmldoc.GetElementsByTagName("Import");
                for (var i = 0; i < elemList.Count; i++)
                {
                    var xmlAttributeCollection = elemList[i].Attributes;
                    if (xmlAttributeCollection == null)
                    {
                        continue;
                    }

                    var attrVal     = xmlAttributeCollection["Project"].Value;
                    var projectPath = Path.Combine(solutionPath, proj.RelativePath).Replace(proj.ProjectName + ".csproj", "");

                    if (attrVal.Contains("MonoTouch"))
                    {
                        projects.Add(new ProjectModel {
                            ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Touch
                        });
                    }
                    else if (attrVal.Contains("Android"))
                    {
                        projects.Add(new ProjectModel {
                            ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Droid
                        });
                    }
                    else if (attrVal.Contains("Portable"))
                    {
                        projects.Add(new ProjectModel {
                            ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Pcl
                        });
                    }
                }
            }
            return(projects);
        }
コード例 #2
0
        public static IList<ProjectModel> GetProjects(SolutionParser solution, string solutionPath)
        {
            var projects = new List<ProjectModel>();

            foreach (var proj in solution.Projects)
            {
                var xmldoc = new XmlDocument();
                try
                {
                    xmldoc.Load(Path.Combine(solutionPath, proj.RelativePath));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                var mgr = new XmlNamespaceManager(xmldoc.NameTable);
                mgr.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");

                var elemList = xmldoc.GetElementsByTagName("Import");
                for (var i = 0; i < elemList.Count; i++)
                {
                    var xmlAttributeCollection = elemList[i].Attributes;
                    if (xmlAttributeCollection == null) continue;

                    var attrVal = xmlAttributeCollection["Project"].Value;
                    var projectPath = Path.Combine(solutionPath, proj.RelativePath).Replace(proj.ProjectName + ".csproj", "");

                    if (attrVal.Contains("MonoTouch"))
                    {
                        projects.Add(new ProjectModel {ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Touch});
                    }
                    else if (attrVal.Contains("Android"))
                    {
                        projects.Add(new ProjectModel {ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Droid});
                    }
                    else if (attrVal.Contains("Portable"))
                    {
                        projects.Add(new ProjectModel {ProjectNamespace = proj.ProjectName, ProjectPath = projectPath, PlatformType = PlatformType.Pcl});
                    }
                }
            }
            return projects;
        }