private YumlClassDiagram GenerateClassDiagram(ProjectDetail rootProjectDetail, ProjectDetailsCollection parentProjectDetailsCollection, bool newlineForEachRelationship) { var classDiagram = new YumlClassDiagram(newlineForEachRelationship); GenerateClassDiagramRelationships(rootProjectDetail, parentProjectDetailsCollection, classDiagram.Relationships, newlineForEachRelationship); return classDiagram; }
private YumlClassWithDetails GenerateClass(ProjectDetail projectDetail) { var detailModel = new YumlClassWithDetails(); detailModel.Name = projectDetail.Name; detailModel.Notes.Add(".Net Version: " + projectDetail.DotNetVersion); return detailModel; }
public YumlClassOutput Translate(ProjectDetail rootProjectDetail, ProjectDetailsCollection parentProjectDetailsCollection, bool newlineForEachRelationship = false) { Logger.Log("Translating ProjectDetail to YumlClassOutput", LogLevel.High); var output = new YumlClassOutput(); output.RootFile = rootProjectDetail.FullPath; output.ClassDiagram = GenerateClassDiagram(rootProjectDetail, parentProjectDetailsCollection, newlineForEachRelationship); return output; }
/// <summary> /// Creates a project detail object from the path to a CS project file. /// </summary> /// <param name="fullFilePath"></param> /// <returns></returns> public ProjectDetail Create(string fullFilePath) { if (!File.Exists(fullFilePath)) { throw new FileNotFoundException(fullFilePath); } var details = new ProjectDetail(); details.FullPath = fullFilePath; DirectoryInfo projectDirectory = new FileInfo(fullFilePath).Directory; //Create an xml doc with correct namespace to analysis project file. XmlDocument doc = new XmlDocument(); XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable); nsMgr.AddNamespace("msb", "http://schemas.microsoft.com/developer/msbuild/2003"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fullFilePath); //fill up all the extra information required for parent project reference details.Name = xmlDoc.SelectSingleNode(@"/msb:Project/msb:PropertyGroup/msb:AssemblyName", nsMgr).InnerText; details.DotNetVersion = xmlDoc.SelectSingleNode(@"/msb:Project/msb:PropertyGroup/msb:TargetFrameworkVersion", nsMgr).InnerText; details.Id = Guid.Parse(xmlDoc.SelectSingleNode(@"/msb:Project/msb:PropertyGroup/msb:ProjectGuid", nsMgr).InnerText); //get all child project references XmlNodeList projectReferences = xmlDoc.SelectNodes(@"/msb:Project/msb:ItemGroup/msb:ProjectReference", nsMgr); IList<ProjectLinkObject> projectReferenceObjects = new List<ProjectLinkObject>(); foreach (XmlElement reference in projectReferences) { string subProjectPath = reference.GetAttribute("Include"); var id = reference.SelectSingleNode("msb:Project", nsMgr).InnerText; projectReferenceObjects.Add(new ProjectLinkObject { FullPath = Path.Combine(projectDirectory.FullName, subProjectPath), Id = Guid.Parse(id) }); } details.ChildProjects.AddRange(projectReferenceObjects); //get all dll references XmlNodeList dllReferences = xmlDoc.SelectNodes(@"/msb:Project/msb:ItemGroup/msb:Reference[not(starts-with(@Include,'System')) and not(starts-with(@Include,'Microsoft.'))]", nsMgr); IList<DllReference> dllReferenceObjects = new List<DllReference>(); foreach (XmlElement reference in dllReferences) { var include = reference.GetAttribute("Include"); dllReferenceObjects.Add(new DllReference { AssemblyName = include.Split(',')[0] }); } details.References.AddRange(dllReferenceObjects); return details; }
public void Add(ProjectDetail project) { var proj = _projectDetails.FirstOrDefault(p => p.Id.Equals(project.Id)); if (proj != null) { proj.AddParentLinks(project.ParentProjects); } else { _projectDetails.Add(project); } }
private void GenerateClassDiagramRelationships(ProjectDetail projectDetail, ProjectDetailsCollection parentProjectDetailsCollection, List<YumlRelationshipBase> existingRelationships, bool newlineForEachRelationship) { AddUnqiueRelationship(existingRelationships, GenerateYumlRelationships(projectDetail, parentProjectDetailsCollection, newlineForEachRelationship)); foreach (var linkObject in projectDetail.ChildProjects) { var detail = parentProjectDetailsCollection.GetById(linkObject.Id); GenerateClassDiagramRelationships(detail, parentProjectDetailsCollection, existingRelationships, newlineForEachRelationship); } }
private List<YumlRelationshipBase> GenerateYumlRelationships(ProjectDetail projectDetail, ProjectDetailsCollection projectDetailsCollection, bool newlineForEachRelationship) { var relationships = new List<YumlRelationshipBase>(); var detailModel = GenerateClass(projectDetail); foreach (var linkObject in projectDetail.ChildProjects) { var childModel = GenerateClass(projectDetailsCollection.GetById(linkObject.Id)); relationships.Add(new SimpleAssociation { Parent = detailModel, Child = childModel }); } foreach (var dllReference in projectDetail.References) { var childModel = GenerateClass(dllReference); relationships.Add(new SimpleAssociation { Parent = detailModel, Child = childModel }); } return relationships; }
public ProjectLinkObject(ProjectDetail projectDetail) { FullPath = projectDetail.FullPath; Id = projectDetail.Id; }