示例#1
0
        private String GetObjectDotDeclaration(DotNode <T> node, DotNotationSettings settings)
        {
            var    shape       = node.Shape == null ? DotShapes.Box : node.Shape;
            var    text        = String.IsNullOrEmpty(node.Text) ? node.GetType().Name : node.Text;
            String strSettings = $"fontsize={settings.FontSize.ToString()} margin={settings.Margin}";

            return($"\"{node.Id}\" [shape=\"{shape.ToString()}\" label=\"{text}\" tooltip=\"{text}\" {strSettings}]");
        }
示例#2
0
        private String GetLinkDotDeclaration(DotNode <T> node, DotNotationSettings settings)
        {
            String strSettings = $"fontsize={settings.FontSize.ToString()} margin={settings.Margin}";

            var sb = new StringBuilder();

            foreach (var nodeRef in node.ParentNodes)
            {
                sb.AppendLine($"\"{nodeRef.DotNode.Id.ToString()}\" -> \"{node.Id.ToString()}\" [label=\"{nodeRef.Name}\" {strSettings}]");
            }

            return(sb.ToString());
        }
示例#3
0
        public string Convert(Flow <T> flow)
        {
            DotNotationSettings _settings = this.Settings == null ? DotNotationSettings.Default : this.Settings;

            var notations = ReadFlow(flow.Actions).Nodes;

            var result = ToDotNotation(notations, Settings);

            return($"digraph G {{\n" +
                   $"compound=true;\n" +    // allow links between edges
                   $"{result.Nodes}\n" +    // declare all the nodes and subgraphs
                   $"{result.Links}\n" +    // links must always be declared all together at the end; including links within subgraphs
                   $"}}");
        }
示例#4
0
        private (string Nodes, string Links) ToDotNotation(List <DotNode <T> > nodes, DotNotationSettings settings = null)
        {
            if (settings == null)
            {
                settings = DotNotationSettings.Default;
            }

            String strSettings = $"fontsize={settings.FontSize.ToString()} margin={settings.Margin}";

            StringBuilder dotSb  = new StringBuilder();
            StringBuilder linkSb = new StringBuilder();

            foreach (var node in nodes)
            {
                if (node.SubNodes.Count > 0)
                {
                    // cluster id is based on the group node id, replacing the guid - by _
                    dotSb.AppendLine($"subgraph cluster_{node.Id.ToString().Replace('-', '_')} {{");
                    dotSb.AppendLine($"    label = \"{node.Text}\"");

                    var subNotation = ToDotNotation(node.SubNodes, settings);

                    dotSb.AppendLine(subNotation.Nodes);
                    linkSb.AppendLine(subNotation.Links);

                    dotSb.AppendLine("}");
                }
                else
                {
                    dotSb.AppendLine(GetObjectDotDeclaration(node, settings));
                    linkSb.AppendLine(GetLinkDotDeclaration(node, settings));
                }
            }

            dotSb.AppendLine(); // just a separation line before declaring the links

            return(dotSb.ToString(), linkSb.ToString());
        }
示例#5
0
 public DotNotationProvider(DotNotationSettings settings = null)
 {
     this.Settings = settings;
 }