private static void ProcessItemGroups(XmlNodeList itemGroups, Project project)
        {
            project.References = new List<Reference>();
            project.SourceFiles = new List<SourceCodeFile>();
            project.ProjectReferences = new List<ProjectReference>();
            foreach (XmlNode itemGroup in itemGroups){
                var childNodes = itemGroup.ChildNodes;
                if (childNodes.Count > 0){
                    switch (childNodes[0].Name){
                        case Constants.ITEM_GROUP_CPPINCLUDE:
                            ProcessSourceItems(childNodes, project, Constants.ITEM_GROUP_CPPINCLUDE);
                            break;
                        case Constants.ITEM_GROUP_CPPCOMPILE:
                            ProcessSourceItems(childNodes, project, Constants.ITEM_GROUP_CPPCOMPILE);
                            break;
                        case Constants.ITEM_GROUP_RESOURCECOMPILE:
                            ProcessSourceItems(childNodes, project, Constants.ITEM_GROUP_RESOURCECOMPILE);
                            break;

                        //case Constants.ITEM_GROUP_PROJECTREFERENCE:
                        //    ProcessProjectReferenceItems(childNodes, project);
                        //    break;
                        //case Constants.ITEM_GROUP_BOOTSTRAPPERPACKAGE:
                        //    break;
                        //case Constants.ITEM_GROUP_REFERENCE:
                        //    ProcessReferenceItems(childNodes, project);
                        //    break;
                    }
                }
            }
        }
        public void Parse(string projFileFullPath, Project project)
        {
            var doc = new XmlDocument();
            var nsmgr = ProjectParserHelper.GetNsMgr(projFileFullPath);
            doc.Load(projFileFullPath);

            var propertyGroupList = doc.SelectNodes("//msbuild:Project/msbuild:PropertyGroup", nsmgr);
            var properties = propertyGroupList?.Cast<XmlNode>().FirstOrDefault(n => n.Attributes?.GetNamedItem("Label")?.Value == "Globals");
            if (properties != null){
                project.RootNamespace = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_ROOTNAMESPACE);
            }

            var itemGroups = doc.SelectNodes("//msbuild:Project/msbuild:ItemGroup", nsmgr);
            ProcessItemGroups(itemGroups, project);
        }
        public void Parse(string projFileFullPath, Project project)
        {
            var doc = new XmlDocument();
            var nsmgr = ProjectParserHelper.GetNsMgr(projFileFullPath);
            doc.Load(projFileFullPath);

            var propertyGroupList = doc.SelectNodes("//msbuild:Project/msbuild:PropertyGroup", nsmgr);
            if (propertyGroupList != null){
                var properties = propertyGroupList[0];
                project.OutputType = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_OUTPUTTYPE);
                project.Configuration = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_CONFIGURATION);
                project.Platform = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_PLATFORM);
                project.ProductVersion = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_PRODUCTVERSION);
                project.RootNamespace = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_ROOTNAMESPACE);
                project.TargetFrameworkVersion = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_TARGETFRAMEWORKVERSION);
                project.SchemaVersion = ProjectParserHelper.GetProperty(properties, Constants.PROPERTY_SCHEMAVERSION);
            }

            var itemGroups = doc.SelectNodes("//msbuild:Project/msbuild:ItemGroup", nsmgr);
            ProcessItemGroups(itemGroups, project);
        }
 //private static void ProcessReferenceItems(XmlNodeList nodes, Project project){
 //    foreach (XmlNode node in nodes){
 //        if (node.Attributes != null){
 //            var name = GetName(node.Attributes[0]);
 //            var specificVersionString = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_SPECIFICVERSION);
 //            var specificVersion = specificVersionString != null && bool.Parse(specificVersionString);
 //            var hintPath = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_HINTPATH);
 //            var reference = new Reference{
 //                Name = name,
 //                SpecificVersion = specificVersion,
 //                HintPath = hintPath
 //            };
 //            project.References.Add(reference);
 //        }
 //    }
 //}
 private static void ProcessSourceItems(XmlNodeList nodes, Project project, string itemType)
 {
     foreach (XmlNode node in nodes){
         SourceCodeFile sourceFile = null;
         if (node.Attributes != null){
             var filename = GetName(node.Attributes[0]);
             var relativePath = GetRelativePath(node.Attributes[0]);
             var subType = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_SUBTYPE);
             var dependentUpon = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_DEPENDENTUPON);
             sourceFile = new SourceCodeFile{
                 FileName = filename,
                 RelativePath = relativePath,
                 IsCompiled = true,
                 SubType = subType,
                 DependentUpon = dependentUpon
             };
         }
         project.SourceFiles.Add(sourceFile);
     }
 }
        private void ProcessProjectEntryLines(string rootPath, IEnumerable<string> lines)
        {
            foreach (var line in lines){
                var projectLine = new SolutionFileProjectEntry(line);
                var fullPath = rootPath + projectLine.RelativePath;
                var lang = MapExtensionToLanguage(projectLine.ProjectFileExtension);

                IProjectFileParser parser;
                switch (lang){
                    case ProjectLanguageTypes.Cs:
                        parser = new CsProjFileParser();
                        break;
                    case ProjectLanguageTypes.Cpp:
                        parser = new CppProjFileParser();
                        break;
                    case ProjectLanguageTypes.Unknown:
                    default:
                        throw new ArgumentOutOfRangeException();
                }
                var project = new Project{
                    Name = projectLine.Name,
                    RelativePath = projectLine.RelativePath,
                    FileExtension = projectLine.ProjectFileExtension,
                    ProjectGuid = projectLine.ProjectGuid,
                    ProjectLanguage = lang,
                };
                Projects.Add(project);
                project.FullPath = fullPath;

                parser.Parse(project.FullPath, project);
            }
        }
 private static void ProcessSourceItems(XmlNodeList nodes, Project project, string itemType)
 {
     foreach (XmlNode node in nodes){
         SourceCodeFile sourceFile = null;
         if (node.Attributes != null){
             var filename = GetName(node.Attributes[0]);
             var relativePath = GetRelativePath(node.Attributes[0]);
             var subType = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_SUBTYPE);
             if (itemType.Equals(Constants.ITEM_GROUP_COMPILE)){
                 var dependentUpon = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_DEPENDENTUPON);
                 sourceFile = new SourceCodeFile{
                     FileName = filename,
                     RelativePath = relativePath,
                     IsCompiled = true,
                     SubType = subType,
                     DependentUpon = dependentUpon
                 };
             } else{
                 var copyToOutputDirectory = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_COPYTOOUTPUTDIRECTORY);
                 sourceFile = new SourceCodeFile{
                     FileName = filename,
                     RelativePath = relativePath,
                     IsCompiled = false,
                     SubType = subType,
                     CopyToOutputDirectory = copyToOutputDirectory
                 };
             }
         }
         project.SourceFiles.Add(sourceFile);
     }
 }
 private static void ProcessReferenceItems(XmlNodeList nodes, Project project)
 {
     foreach (XmlNode node in nodes){
         if (node.Attributes != null){
             var name = GetName(node.Attributes[0]);
             var specificVersionString = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_SPECIFICVERSION);
             var specificVersion = specificVersionString != null && bool.Parse(specificVersionString);
             var hintPath = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_HINTPATH);
             var reference = new Reference{
                 Name = name,
                 SpecificVersion = specificVersion,
                 HintPath = hintPath
             };
             project.References.Add(reference);
         }
     }
 }
 private static void ProcessProjectReferenceItems(XmlNodeList nodes, Project project)
 {
     foreach (XmlNode node in nodes){
         var name = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_NAME);
         var projectGuid = ProjectParserHelper.GetProperty(node, Constants.PROPERTY_PROJECT);
         if (node.Attributes != null){
             var relativePath = GetRelativePath(node.Attributes[0]);
             var projectReference = new ProjectReference{
                 Name = name,
                 ProjectGuid = projectGuid,
                 RelativePath = relativePath
             };
             project.ProjectReferences.Add(projectReference);
         }
     }
 }