public DependencyEngineListener(DependencyEngine dependencyEngine, Action<string> onWalkComplete, bool indent = true, VisualisationOptions visualisationOptions = null)
 {
     this.dependencyEngine = dependencyEngine;
     this.onWalkComplete = onWalkComplete;
     this.indent = indent;
     this.visualisationOptions = visualisationOptions ?? new VisualisationOptions();
     dependencyEngine.AddInstrumentation(this);
 }
Exemplo n.º 2
0
 public DependencyEngineListener(DependencyEngine dependencyEngine, Action <string> onWalkComplete, bool indent = true, VisualisationOptions visualisationOptions = null)
 {
     this.dependencyEngine     = dependencyEngine;
     this.onWalkComplete       = onWalkComplete;
     this.indent               = indent;
     this.visualisationOptions = visualisationOptions ?? new VisualisationOptions();
     dependencyEngine.AddInstrumentation(this);
 }
 public static string ToDotFormat(this DependencyEngine dependencyEngine, 
     string title = null,
     Func<VertexVisualProperties, VertexVisualProperties> overrideVisualProperties = null,
     VisualisationOptions options = null)
 {
     var graphSnapshot = dependencyEngine.GetGraphSnapshot();
     var visualsaition = new DotVisualisation(graphSnapshot);
     return visualsaition.Generate(title, overrideVisualProperties ?? (v => v), true, options ?? new VisualisationOptions());
 }
Exemplo n.º 4
0
        public static string ToDotFormat(this DependencyEngine dependencyEngine,
                                         string title = null,
                                         Func <VertexVisualProperties, VertexVisualProperties> overrideVisualProperties = null,
                                         VisualisationOptions options = null)
        {
            var graphSnapshot = dependencyEngine.GetGraphSnapshot();
            var visualsaition = new DotVisualisation(graphSnapshot);

            return(visualsaition.Generate(title, overrideVisualProperties ?? (v => v), true, options ?? new VisualisationOptions()));
        }
Exemplo n.º 5
0
        public string Generate(string title, Func <VertexVisualProperties, VertexVisualProperties> overrideVisualProperties, bool indent, VisualisationOptions visualisationOptions)
        {
            var labels          = new StringBuilder();
            var graphDefinition = new StringBuilder();
            var currentGraph    = graph;
            var thisNodes       = graph.Verticies.Where(v => v.Data.Label == "this").ToArray();

            foreach (var source in thisNodes)
            {
                currentGraph.DeleteVertex(source.Data);
            }
            if (!visualisationOptions.ShowFormulas)
            {
                currentGraph = ExcludeFormulaNodes(currentGraph);
            }

            foreach (var vertex in currentGraph.Verticies)
            {
                var properties = new VertexVisualProperties(vertex.Id)
                {
                    Label = vertex.Data.Label
                };

                if (!visualisationOptions.ShowRoot && vertex.Data.VisualisationInfo.IsRoot)
                {
                    continue;
                }

                switch (vertex.Data.VisualisationInfo.NodeType)
                {
                case NodeType.Formula:
                    properties.Color = "lightblue";
                    properties.AddCustomProperty("style", "filled");
                    properties.AddCustomProperty("shape", "octagon");
                    break;

                case NodeType.Member:
                    properties.AddCustomProperty("shape", "box");
                    properties.AddCustomProperty("style", "filled");
                    properties.AddCustomProperty("style", "rounded");
                    break;

                case NodeType.Action:
                    properties.AddCustomProperty("style", "filled");
                    properties.Color = "green";
                    break;
                }

                if (overrideVisualProperties != null)
                {
                    properties = overrideVisualProperties(properties);
                }

                labels.Append(properties);
                if (indent)
                {
                    labels.AppendLine();
                }
            }

            foreach (var edge in currentGraph.Edges)
            {
                if (!visualisationOptions.ShowRoot && (edge.Source.Data.VisualisationInfo.IsRoot || edge.Target.Data.VisualisationInfo.IsRoot))
                {
                    continue;
                }

                graphDefinition.Append(indent ? "    " : string.Empty).AppendFormat("{0} -> {1};", edge.Source.Id, edge.Target.Id);
                if (indent)
                {
                    graphDefinition.AppendLine();
                }
            }

            if (indent)
            {
                return(string.Format(@"digraph {0} {{
{1}
{2}}}", title, labels, graphDefinition));
            }
            return(string.Format(@"digraph {0} {{ {1} {2}}}", title, labels, graphDefinition));
        }
Exemplo n.º 6
0
        public string Generate(string title, Func<VertexVisualProperties, VertexVisualProperties> overrideVisualProperties, bool indent, VisualisationOptions visualisationOptions)
        {
            var labels = new StringBuilder();
            var graphDefinition = new StringBuilder();
            var currentGraph = graph;
            var thisNodes = graph.Verticies.Where(v => v.Data.Label == "this").ToArray();
            foreach (var source in thisNodes)
            {
                currentGraph.DeleteVertex(source.Data);
            }
            if (!visualisationOptions.ShowFormulas)
            {
                currentGraph = ExcludeFormulaNodes(currentGraph);
            }

            foreach (var vertex in currentGraph.Verticies)
            {
                var properties = new VertexVisualProperties(vertex.Id)
                {
                    Label = vertex.Data.Label
                };

                if (!visualisationOptions.ShowRoot && vertex.Data.VisualisationInfo.IsRoot) continue;

                switch (vertex.Data.VisualisationInfo.NodeType)
                {
                    case NodeType.Formula:
                        properties.Color = "lightblue";
                        properties.AddCustomProperty("style", "filled");
                        properties.AddCustomProperty("shape", "octagon");
                        break;
                    case NodeType.Member:
                        properties.AddCustomProperty("shape", "box");
                        properties.AddCustomProperty("style", "filled");
                        properties.AddCustomProperty("style", "rounded");
                        break;
                    case NodeType.Action:
                        properties.AddCustomProperty("style", "filled");
                        properties.Color = "green";
                        break;
                }

                if (overrideVisualProperties != null)
                {
                    properties = overrideVisualProperties(properties);
                }

                labels.Append(properties);
                if (indent) labels.AppendLine();
            }

            foreach (var edge in currentGraph.Edges)
            {
                if (!visualisationOptions.ShowRoot && (edge.Source.Data.VisualisationInfo.IsRoot || edge.Target.Data.VisualisationInfo.IsRoot))
                    continue;

                graphDefinition.Append(indent ? "    " : string.Empty).AppendFormat("{0} -> {1};", edge.Source.Id, edge.Target.Id);
                if (indent) graphDefinition.AppendLine();
            }

            if (indent)
            {
                return string.Format(@"digraph {0} {{
            {1}
            {2}}}", title, labels, graphDefinition);
            }
            return string.Format(@"digraph {0} {{ {1} {2}}}", title, labels, graphDefinition);
        }