private static void GatherEdgesAux(ProjectInfo projectInfo, ProjectDependenciesGraph projectDependenciesGraph, Dictionary<ProjectDesignator, ProjectInfoVertex> verticesMap, Dictionary<ProjectDesignator, bool> visitedMap) { // TODO IMM HI: abstract the visitor -> such code is duplicated in DgmlProjectDependenciesModelExporter if (projectInfo == null) throw new ArgumentNullException("projectInfo"); if (projectDependenciesGraph == null) throw new ArgumentNullException("projectDependenciesGraph"); if (verticesMap == null) throw new ArgumentNullException("verticesMap"); ProjectDesignator projectDesignator = ProjectDesignator.FromProjectInfo(projectInfo); ProjectInfoVertex projectInfoVertex = verticesMap[projectDesignator]; visitedMap[projectDesignator] = true; foreach (ProjectDependency projectDependency in projectInfo.ProjectDependencies) { ProjectDesignator dependentProjectDesignator = ProjectDesignator.FromProjectDependency(projectDependency); ProjectInfoVertex dependentProjectInfoVertex = verticesMap[dependentProjectDesignator]; projectDependenciesGraph.AddEdge( new Edge<ProjectInfoVertex>( projectInfoVertex, dependentProjectInfoVertex)); if (visitedMap.ContainsKey(dependentProjectDesignator)) { // already processed - skip it continue; } GatherEdgesAux(dependentProjectInfoVertex.ProjectInfo, projectDependenciesGraph, verticesMap, visitedMap); } }
private static void ExportAux(XElement linksElement, ProjectDependenciesModel projectDependenciesModel, ProjectInfo projectInfo, Dictionary<ProjectDesignator, bool> visitedMap) { if (linksElement == null) throw new ArgumentNullException("linksElement"); if (projectDependenciesModel == null) throw new ArgumentNullException("projectDependenciesModel"); if (projectInfo == null) throw new ArgumentNullException("projectInfo"); if (visitedMap == null) throw new ArgumentNullException("visitedMap"); ProjectDesignator projectDesignator = ProjectDesignator.FromProjectInfo(projectInfo); visitedMap[projectDesignator] = true; foreach (ProjectDependency projectDependency in projectInfo.ProjectDependencies) { ProjectDesignator dependentProjectDesignator = ProjectDesignator.FromProjectDependency(projectDependency); ProjectInfo dependentProjectInfo = projectDependenciesModel.ProjectInfos[dependentProjectDesignator]; linksElement.Add( new XElement( _DgmlNamespace + "Link", new XAttribute("Source", CreateProjectDisplayString(projectInfo)), new XAttribute("Target", CreateProjectDisplayString(dependentProjectInfo)), new XAttribute("Label", projectDependency.ProjectVersion))); if (visitedMap.ContainsKey(dependentProjectDesignator)) { // already processed - skip it continue; } ExportAux(linksElement, projectDependenciesModel, dependentProjectInfo, visitedMap); } }
public ProjectInfoVertex(ProjectInfo projectInfo) { if (projectInfo == null) throw new ArgumentNullException("projectInfo"); _projectInfo = projectInfo; }
private void ObtainProjectVersion(ProjectInfo projectInfo, string projectRelativePath) { if (projectInfo == null) throw new ArgumentNullException("projectInfo"); if (projectRelativePath == null) throw new ArgumentNullException("projectRelativePath"); string versionFileName = "Version.xml"; string versionFilePath = string.Format("{0}/{1}", projectRelativePath, versionFileName); string versionFileContents = _svnClient.GetFileContents(versionFilePath); if (string.IsNullOrEmpty(versionFileContents)) { projectInfo.ProjectVersion = "?"; return; } string projectVersion = _versionFileAnalyzer.GetProjectVersion(versionFileContents); if (string.IsNullOrEmpty(projectVersion)) { throw new ArgumentException( string.Format( "Couldn't obtain project version for project {0} (configuration: {1}).", projectInfo.ProjectName, projectInfo.ProjectConfiguration)); } projectInfo.ProjectVersion = projectVersion; }
private ProjectInfo ObtainProjectInfo(string projectName, string projectConfiguration) { if (projectName == null) throw new ArgumentNullException("projectName"); if (projectConfiguration == null) throw new ArgumentNullException("projectConfiguration"); var projectInfo = new ProjectInfo { ProjectName = projectName, ProjectConfiguration = projectConfiguration, }; string projectConfigurationUpper = projectConfiguration.ToUpper(); string projectRelativePath = (projectConfigurationUpper == "TRUNK" || projectConfigurationUpper == "PRODUCTION") ? string.Format("{0}/trunk", projectName) : string.Format("{0}/branches/{1}", projectName, projectConfiguration); ObtainProjectVersion(projectInfo, projectRelativePath); ObtainProjectDependencies(projectInfo, projectRelativePath); return projectInfo; }
private void ObtainProjectDependencies(ProjectInfo projectInfo, string projectRelativePath) { if (projectInfo == null) throw new ArgumentNullException("projectInfo"); if (projectRelativePath == null) throw new ArgumentNullException("projectRelativePath"); string buildFileContents = _svnClient.GetFileContentsByExt(projectRelativePath,".build"); if (buildFileContents != null) { foreach (var projectDependency in _buildFileAnalyzer.GetProjectDependencies(buildFileContents)) { projectInfo.ProjectDependencies.Add(projectDependency); } } }
private bool HasPathTo(ProjectInfo searchedProject, ProjectInfo rootProject, ProjectDependenciesModel model) { foreach (ProjectDependency projectDependency in searchedProject.ProjectDependencies) { if (projectDependency.ProjectName == rootProject.ProjectName && projectDependency.ProjectConfiguration == rootProject.ProjectConfiguration && rootProject.ProjectVersion == projectDependency.ProjectVersion) return true; return HasPathTo(model.ProjectInfos[new ProjectDesignator(projectDependency.ProjectName,projectDependency.ProjectConfiguration)],rootProject, model); } return false; }
private static object CreateProjectDisplayString(ProjectInfo projectInfo) { if (projectInfo == null) throw new ArgumentNullException("projectInfo"); return string.Format("{0} - {1} - {2}", projectInfo.ProjectName, projectInfo.ProjectConfiguration, projectInfo.ProjectVersion); }
public static ProjectDesignator FromProjectInfo(ProjectInfo projectInfo) { if (projectInfo == null) throw new ArgumentNullException("projectInfo"); return new ProjectDesignator(projectInfo.ProjectName, projectInfo.ProjectConfiguration); }