public static OutputResponse CreateOutPut(AnalysisRequest request, RootNode rootNode) { if (request == null) throw new ArgumentNullException("request"); if (rootNode == null) throw new ArgumentNullException("rootNode"); IOutputProvider outputProvider = OutputFactory.CreateProvider(request.OutPutType); return outputProvider.Create(rootNode, request.OutPutFolder); }
private YumlClassDiagram GenerateClassDiagram(RootNode rootNode, bool newlineForEachRelationship) { var classDiagram = new YumlClassDiagram(newlineForEachRelationship); foreach (var detail in rootNode.ProjectDetails) { classDiagram.Relationships.AddRange(GenerateYumlRelationships(detail, rootNode.ProjectDetails, newlineForEachRelationship)); } return classDiagram; }
public YumlClassOutput Translate(RootNode rootNode, bool newlineForEachRelationship = false) { Logger.Log("Translating rootNode to YumlClassOutput", LogLevel.High); var output = new YumlClassOutput(); output.RootFile = rootNode.File.FullName; output.ClassDiagram = GenerateClassDiagram(rootNode, newlineForEachRelationship); return output; }
public OutputResponse Create(RootNode rootNode, string outputFolder) { Logger.Log("Creating instance of YumlReferenceListOutputProvider", LogLevel.High); var translator = new RootNodeToYumlClassDiagramTranslator(); var yumlClassOutput = translator.Translate(rootNode, true); string filePath = Path.Combine(Path.GetFullPath(outputFolder), Path.Combine(outputFolder, rootNode.File.Name + ".yuml")); FileHandler.WriteToOutputFile(filePath, yumlClassOutput.ClassDiagram.ToString()); return new OutputResponse { Success = true, Path = filePath }; }
/// <summary> /// Find projects that are referenced in a solution file and creates a list of references to them. /// </summary> /// <param name="rootNode"></param> /// <returns></returns> public List<InvestigationLink> FindAllProjectLinks(RootNode rootNode) { var solution = new Solution(rootNode.File.FullName); var projects = solution.Projects.Where(p => p.RelativePath.EndsWith(".csproj")).ToList(); var projectLinks = new List<InvestigationLink>(projects.Count); projectLinks.AddRange( from project in projects let path = Path.Combine(rootNode.Directory.FullName, project.RelativePath) select new InvestigationLink { Parent = null, FullPath = path } ); return projectLinks; }
public OutputResponse Create(RootNode rootNode, string outputFolder) { Logger.Log("Creating instance of YumlUrlOutputProvider", LogLevel.High); var translator = new RootNodeToYumlClassDiagramTranslator(); var yumlClassOutput = translator.Translate(rootNode, true); string outputTree = YumlHelper.CommaSeperateRelationshipsOnMultipleLines(YumlHelper.ReplaceSpaces(yumlClassOutput.ClassDiagram.ToString())); string filePath = Path.Combine(Path.GetFullPath(outputFolder), Path.Combine(outputFolder, rootNode.File.Name + ".url.yuml")); FileHandler.WriteToOutputFile(filePath, YumlHelper.YumlClassUrl + outputTree); return new OutputResponse { Success = true, Path = filePath }; }
public static void Process(RootNode rootNode) { switch (rootNode.NodeType) { case RootNodeType.SLN: ProcessSlnRootNode(rootNode); return; case RootNodeType.CSPROJ: ProcessCsProjRootNode(rootNode); return; default: throw new ArgumentOutOfRangeException(); } }
public OutputResponse Create(RootNode rootNode, string outputFolder) { Logger.Log("Creating instance of YumlImageOutputProvider", LogLevel.High); var translator = new RootNodeToYumlClassDiagramTranslator(); var yumlClassOutput = translator.Translate(rootNode, true); var serverImagePath = YumlHelper.GenerateImageOnYumlServer(yumlClassOutput); //have generated the image on the yuml server, now download the file. string basePath = Path.GetFullPath(outputFolder); var outputFileName = Path.Combine(basePath, rootNode.File.Name + ".png"); YumlHelper.DownloadYumlServerImage(outputFileName, serverImagePath); return new OutputResponse { Success = true, Path = outputFileName }; }
/// <summary> /// Creates the rootNode collection from the analysisRequest. Will interigate the solution and proejcts to find all other projects and their relationships. /// </summary> /// <param name="request"></param> /// <returns></returns> public static RootNode CreateRootNode(AnalysisRequest request) { if (!File.Exists(request.RootFile)) { throw new FileNotFoundException(request.RootFile); } var rootFileInfo = new FileInfo(request.RootFile); var rootNode = new RootNode { Directory = rootFileInfo.Directory, File = rootFileInfo, Name = rootFileInfo.Name, NodeType = DetermineRootNodeType(rootFileInfo.FullName), SearchDepth = request.NumberOfLevelsToDig }; return rootNode; }
public OutputResponse Create(RootNode rootNode, string outputFolder) { Logger.Log("Creating instance of SinglePageHtmlDocumentOutputProvider", LogLevel.High); var translator = new RootNodeToYumlClassDiagramTranslator(); var yumlClassOutput = translator.Translate(rootNode, true); var builder = new StringBuilder(); builder.AppendLine(@"<html>"); builder.AppendLine(@"<head>"); builder.AppendLine(@"<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>"); builder.AppendLine(@"<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js'></script>"); builder.AppendLine(@"<link rel='stylesheet' type='text/css' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/eggplant/jquery-ui.css' />"); builder.AppendLine(@" <script> $(document).ready(function() { $('#accordian').accordion(); $('li').click(function() { $('#accordian').accordion( 'option', 'active', $('#accordian .projectReference').index($($(this).find('a').attr('href')))); return false; }); }); </script>" ); builder.AppendLine(@"</head>"); builder.AppendLine(@"<body>"); builder.AppendLine(string.Format(@"<h1>All references for: {0}</h1>", yumlClassOutput.RootFile)); var rootNodeOutputFileName = ConvertRootFileFullPathIntoOutputPngFileName(outputFolder, yumlClassOutput.RootFile); YumlHelper.DownloadYumlServerImage(rootNodeOutputFileName, YumlHelper.GenerateImageOnYumlServer(yumlClassOutput)); builder.AppendLine(String.Format(@"<p>Image for whole reference list: <a href='{0}' target='_blank'> View Yuml Image</a></p>", rootNodeOutputFileName)); builder.AppendLine(@"<div id='accordian'>"); //then for each project details item in the collection need to generate an image and list of links that it references and what references it foreach (var projectDetail in rootNode.ProjectDetails) { Logger.Log(string.Format("generating HTML output for projectDetail: '{0}'", projectDetail.FullPath), LogLevel.High); var projectOutput = translator.Translate(projectDetail, rootNode.ProjectDetails, true); builder.AppendLine(string.Format(@"<h2>{0}</h2>", Path.GetFileName(projectOutput.RootFile))); builder.AppendLine(string.Format(@"<div class='projectReference' id='{0}'>", projectDetail.Id)); if (!string.IsNullOrWhiteSpace(projectOutput.ClassDiagram.ToString())) { var projectOutputFileName = ConvertRootFileFullPathIntoOutputPngFileName(outputFolder, projectOutput.RootFile); YumlHelper.DownloadYumlServerImage(projectOutputFileName, YumlHelper.GenerateImageOnYumlServer(projectOutput)); builder.AppendLine(string.Format(@"<h2>{0} - <a href='{1}' target='_blank'>View Yuml Image</a></h2>", Path.GetFileName(projectOutput.RootFile), projectOutputFileName)); } if (projectDetail.ChildProjects.Any()) { builder.AppendLine(@"<p>This project references:</p>"); builder.AppendLine(@"<ul>"); foreach (var reference in projectDetail.ChildProjects) { builder.AppendLine(string.Format(@"<li><a href='#{0}'>{1}</a></li>", reference.Id, Path.GetFileName(reference.FullPath))); } builder.AppendLine(@"</ul>"); } else { builder.AppendLine("<p>This project does not reference any other projects</p>"); } if (projectDetail.ParentProjects.Any()) { builder.AppendLine(@"<p>This project is referenced by:</p>"); builder.AppendLine(@"<ul>"); foreach (var reference in projectDetail.ParentProjects) { builder.AppendLine(string.Format(@"<li><a href='#{0}'>{1}</a></li>", reference.Id, Path.GetFileName(reference.FullPath))); } builder.AppendLine(@"</ul>"); } else { builder.AppendLine("<p>This project is not referenced by any other projects</p>"); } builder.AppendLine(@"</div>"); } builder.AppendLine(@"</div>"); builder.AppendLine(@"</body>"); builder.AppendLine(@"</html>"); var htmlOutputFilePath = Path.Combine(outputFolder, "references.html"); File.WriteAllText(htmlOutputFilePath, builder.ToString()); return new OutputResponse { Path = htmlOutputFilePath, Success = true }; }
private static void ProcessLinks(List<InvestigationLink> linksToBeInvestigated, RootNode rootNode) { while (linksToBeInvestigated.Any()) { var item = linksToBeInvestigated[0]; linksToBeInvestigated.RemoveAt(0); var link = new ProjectLinkObject {FullPath = item.FullPath}; var projectDetail = new ProjectFileManager().Create(link); if (item.Parent != null) { projectDetail.ParentProjects.Add(item.Parent); } link.Id = projectDetail.Id; //get all child links and create link investigations for them linksToBeInvestigated.AddRange(projectDetail.ChildProjects.Select(p => new InvestigationLink { FullPath = p.FullPath, Parent = link }).ToList()); rootNode.ProjectDetails.Add(projectDetail); } }
private static void ProcessCsProjRootNode(RootNode rootNode) { ProcessLinks(new List<InvestigationLink> { new InvestigationLink {FullPath = rootNode.File.FullName, Parent = null} }, rootNode); }
private static void ProcessSlnRootNode(RootNode rootNode) { var projectLinks = new SolutionFileManager().FindAllProjectLinks(rootNode); ProcessLinks(projectLinks, rootNode); }