public static ProjectSection CreateSection(ProjectSectionContext context, ProjectInfo projectInfo) { if (context != null) { ProjectSection projectSection = context.GetProjectSection( projectInfo.ProjectGuid); if (projectSection != null) { return(projectSection); } } return(CreateSection(context, projectInfo.ProjectPath)); }
protected virtual void CreateChildren(IList <ProjectInfo> referenceProjects) { if (_context == null) { throw new InvalidOperationException( "There is no project section context attached to this project."); } if (referenceProjects == null || referenceProjects.Count == 0) { return; } for (int i = 0; i < referenceProjects.Count; i++) { ProjectInfo referenceProject = referenceProjects[i]; if (referenceProject == null || !referenceProject.IsValid) { continue; } // First search the registered projects to avoid duplications ProjectSection childSection = _context.GetProjectSection( referenceProject.ProjectGuid); if (childSection == null) { childSection = ProjectSectionFactory.CreateSection( _context, referenceProject.ProjectPath); } if (childSection != null) { this.AddChild(childSection); } } }
public static IList <ProjectSection> CreateSections(string sourceFile, string platform, string configuration, HashSet <string> targetProjectGuids) { sourceFile = Path.GetFullPath( Environment.ExpandEnvironmentVariables(sourceFile)); string fileExt = Path.GetExtension(sourceFile); if (String.IsNullOrEmpty(fileExt)) { return(null); } ProjectSectionContext context = new ProjectSectionContext(); context.Platform = platform; context.Configuration = configuration; if (targetProjectGuids != null && targetProjectGuids.Count != 0) { context.RegisterTargets(targetProjectGuids); } List <ProjectSection> projectSections = new List <ProjectSection>(); if (fileExt.Equals(".sln", StringComparison.OrdinalIgnoreCase)) { context.SolutionFile = sourceFile; IList <ProjectInfo> listProjectInfo = GetProjectInfo(sourceFile); if (listProjectInfo != null && listProjectInfo.Count != 0) { // Register projects for reference resolution... context.RegisterInfo(listProjectInfo); // If we are documenting all, then add the targets... if (targetProjectGuids == null || targetProjectGuids.Count == 0) { for (int i = 0; i < listProjectInfo.Count; i++) { ProjectInfo projectInfo = listProjectInfo[i]; if (projectInfo != null && projectInfo.IsValid) { context.RegisterTarget(projectInfo.ProjectGuid); } } } for (int i = 0; i < listProjectInfo.Count; i++) { ProjectInfo projectInfo = listProjectInfo[i]; if (projectInfo != null && projectInfo.IsValid && context.IsTarget(projectInfo.ProjectGuid)) { ProjectSection projectSection = context.GetProjectSection( projectInfo.ProjectGuid); if (projectSection == null) { projectSection = CreateSection(context, projectInfo); } if (projectSection != null) { projectSections.Add(projectSection); context.RegisterSection(projectSection); } } } } } else { ProjectSection projectSection = CreateSection(context, sourceFile); if (projectSection != null) { projectSections.Add(projectSection); context.RegisterSection(projectSection); } } return(projectSections); }