Beispiel #1
0
        public Node GenerateDiagram(DiagramDefinition diagramDef)
        {
            Node scoped = null;
            var toBeScoped = CachedTree.DeepClone();
            // This boilerplate syntax will look better in C# 7, dont change untill then
            if (diagramDef.Scope is RootScope)
            {
                scoped = toBeScoped;
            }
            if (diagramDef.Scope is DocumentScope)
            {
                scoped = SemanticTreeBuilder.FindDocument(toBeScoped, ((DocumentScope) diagramDef.Scope).Name);
            }
            if (diagramDef.Scope is ClassScope)
            {
                scoped = SemanticTreeBuilder.FindClass(toBeScoped, ((ClassScope)diagramDef.Scope).Name);
            }
            if (diagramDef.Scope is NamespaceScope)
            {
                scoped = SemanticTreeBuilder.FindNamespace(toBeScoped, ((NamespaceScope) diagramDef.Scope).Name);
            }
            if (diagramDef.Scope is ProjectScope)
            {
                scoped = SemanticTreeBuilder.FindProject(toBeScoped, ((ProjectScope) diagramDef.Scope).Name);
            }

            scoped = scoped.ApplyFilters(diagramDef.Filters)
                .RelayoutBasedOnDependencies();

            return diagramDef.DependencyDown ? ReverseChildren(scoped) : scoped;
        }
Beispiel #2
0
 public void GeneratesWholeSolutionDiagramWithoutNamespacesWithoutCausingDuplicates()
 {
     var filters = DiagramDefinition.DefaultFilters;
     filters.Add(new RemoveContainers(true));
     var diagramDef = new DiagramDefinition("",
         new RootScope(), new OutputSettings (SlnDir + "IntegrationTests\\NoContainers.png"), filters, true,false);
     var tree = GeneratorForThisSolution.GenerateDiagram(diagramDef);
     TreeAssert.DoesNotContainDuplicates(tree);
 }
 public void GenerateAlignmentTest()
 {
     var modelDef = new DiagramDefinition("",
         new NamespaceScope {Name = @"Tests\Integration\Samples"},
         new OutputSettings (SlnDir + @"IntegrationTests\VerticalAnonymousLayer.png"),
         new List<Filter> {new RemoveTests(true) }
         );
     var tree = GeneratorForThisSolution.GenerateDiagram(modelDef);
     BitmapRenderer.RenderTreeToBitmap(tree,modelDef.DependencyDown, modelDef.Output);
 }
        public void CreatesNewTreesForEachRequest()
        {
            var generator =
                new DiagramGenerator(DevArchSolution.FromPath(TestExtesions.TestSolutions.WithSolFolders));
            var def1 = new DiagramDefinition("",new RootScope(), new OutputSettings(""),
                new List<Filter>{new MaxDepth(1)});
            var def2 = new DiagramDefinition("", new RootScope(), new OutputSettings(""),
                new List<Filter> { new MaxDepth(2) });

            var diagram1 = generator.GenerateDiagram(def1);
            var diagram2 = generator.GenerateDiagram(def2);

            //Assert
            diagram1.Should().NotBeSameAs(diagram2);
            diagram1.Height().Should().Be(1);
            diagram2.Height().Should().Be(2);
        }
        public static DiagramDefinition ParseDiagramDefinition(string name,string content)
        {
            var reader = XmlReader.Create(new StringReader(content),new XmlReaderSettings {IgnoreComments = true});
            reader.Read();
            var xmlDoc = new XmlDocument();
            xmlDoc.Load(reader);

            var modelRoot = xmlDoc.RequireTag("Diagram");
            var scopeHolderNode = modelRoot.RequireTag("Scope");
            var output = modelRoot.RequireTag("Output");
            // Can be null
            var filtersNode = modelRoot["Filters"];

            // Dependency direction
            var dependencyAttributeValue = GetAttribute(modelRoot, "DependencyDirection");
            var dependencyDown = dependencyAttributeValue?.Equals("Down") ?? true;

            var hideAttribute = GetAttribute(modelRoot, "HideAnonymousLayers");
            var hideAnonymous = hideAttribute?.Equals("true") ?? true;

            // Scope
            var scope = ParseScope(scopeHolderNode);

            // OutputSettings
            var outputSettings = ParseOutputSettings(output);

            // Filters
            IEnumerable<Filter> filters = DiagramDefinition.DefaultFilters;
            if (filtersNode?.ChildNodes != null)
            {
                filters = filtersNode.ChildNodes.Cast<XmlNode>().Select(ParseFilter);
            }

            filters = AddDefaultFilters(filters);

            var diagramDefinition = new DiagramDefinition(name, scope, outputSettings, filters, dependencyDown, hideAnonymous);
            return diagramDefinition;
        }
 public DiagramDefinitionParseResult(DiagramDefinition definition)
 {
     Definition = definition;
     Succeed = true;
     Exception = null;
 }
 public DiagramDefinitionParseResult(Exception exception)
 {
     Exception = exception;
     Succeed = false;
     Definition = null;
 }