コード例 #1
0
        private static void AppendCollectorPipeFormatting(IGraphNode node, NodeMetadata metadata, StringBuilder result)
        {
            var label      = metadata.GetCount(node) == 0 ? "" : "label=Collector, ";
            var uniqueName = metadata.GetQuotedUniqueName(node);

            AppendFormat(uniqueName, $@"{label}color = ""#c361f4""", result);
        }
コード例 #2
0
        public static StringBuilder AppendFormatting(IGraphNode node, NodeMetadata metadata)
        {
            void ProcessNode(IGraphNode node_, NodeMetadata metadata_, StringBuilder result_)
            {
                PipeAppendersByType[node_.GetType().GetGenericTypeDefinition()](node_, metadata_, result_);
            }

            return(DotGraph.ProcessTree(node, new StringBuilder(), ProcessNode, delegate { }, metadata));
        }
コード例 #3
0
        private static void AppendFunctionalPipe(IGraphNode node, NodeMetadata metadata, StringBuilder result)
        {
            switch (node)
            {
            case IFunctionPipe functionPipe:
                AppendFunctionPipe(functionPipe, metadata, result);
                break;

            case IJoinedPipes joinedPipes:
                AppendJoinedPipe(joinedPipes, metadata, result);
                break;
            }
        }
コード例 #4
0
        private static void AppendFunctionPipeFormatting(IGraphNode node, NodeMetadata metadata, StringBuilder result)
        {
            var output = ((IFunctionPipe)node).Output;

            var label            = metadata.GetCount(output) == 0 ? "" : $"label={metadata.GetQuotedDisplayName(output)}, ";
            var outputUniqueName = metadata.GetQuotedUniqueName(output);

            AppendFormat(outputUniqueName, $@"{label}color=""#9fbff4""", result);

            var functionLabel      = metadata.GetCount(node) == 0 ? "" : $"label={metadata.GetQuotedDisplayName(node)}, ";
            var functionUniqueName = metadata.GetQuotedUniqueName(node);

            AppendFormat(functionUniqueName, $@"{functionLabel}shape=invhouse", result);
        }
コード例 #5
0
ファイル: DotGraph.cs プロジェクト: claremacrae/Pipelines
        public static string FromPipeline <T>(InputPipe <T> root)
        {
            var metadata = new NodeMetadata(root);

            return($@"
digraph G {{ node [style=filled, shape=rec]

# Nodes
{DotGraphNodes.AppendNodeAndChildren(root, metadata)}

# Formatting
{DotGraphFormatting.AppendFormatting(root, metadata)}
{DotGraphRanking.AppendRankings(root, metadata)}

}}
".Trim());
        }
コード例 #6
0
        private static void AppendFunctionPipe(IFunctionPipe functionPipe, NodeMetadata metadata, StringBuilder result)
        {
            var predecessorFunctionPipe = functionPipe.Predecessor as IFunctionPipe;

            var input         = metadata.GetQuotedUniqueName(predecessorFunctionPipe?.Output ?? functionPipe.Predecessor);
            var function      = metadata.GetQuotedUniqueName(functionPipe);
            var output        = metadata.GetQuotedUniqueName(functionPipe.Output);
            var collectorNode = functionPipe.Collector;

            if (collectorNode != null)
            {
                var collectorUniqueName = metadata.GetQuotedUniqueName(collectorNode);
                output = $"{{{output}, {collectorUniqueName}}}";
            }

            result.AppendLine($"{input} -> {function} -> {output}");
        }
コード例 #7
0
        private static void AppendJoinedPipe(IJoinedPipes joinedPipes, NodeMetadata metadata, StringBuilder result)
        {
            var predecessors = joinedPipes.Predecessors;

            var input1        = metadata.GetQuotedUniqueName(predecessors.Item1.Output);
            var input2        = metadata.GetQuotedUniqueName(predecessors.Item2.Output);
            var function      = metadata.GetQuotedUniqueName(joinedPipes);
            var output        = metadata.GetQuotedUniqueName(joinedPipes.Output);
            var collectorNode = joinedPipes.Collector;

            if (collectorNode != null)
            {
                var collectorUniqueName = metadata.GetQuotedUniqueName(collectorNode);
                output = $"{{{output}, {collectorUniqueName}}}";
            }

            result.AppendLine($"{{{input1}, {input2}}} -> {function} -> {output}");
        }
コード例 #8
0
 public static StringBuilder AppendRankings(IGraphNode node, NodeMetadata metadata)
 {
     return(DotGraph.ProcessTree(node, new StringBuilder(), delegate { }, ProcessChildRanking, metadata));
 }
コード例 #9
0
 private static void ProcessChildRanking(IGraphNode node, IGraphNode listener, NodeMetadata metadata,
                                         StringBuilder result)
 {
     if (listener.GetType().GetGenericTypeDefinition() == typeof(CollectorPipe <>))
     {
         var listenerUniqueName = metadata.GetQuotedUniqueName(listener);
         result.AppendLine($@"{{ rank=same; {metadata.GetQuotedUniqueName(node)}, {listenerUniqueName}}}");
     }
 }
コード例 #10
0
        private static void AppendInputPipeFormatting(IGraphNode node, NodeMetadata metadata, StringBuilder result)
        {
            var uniqueName = metadata.GetQuotedUniqueName(node);

            AppendFormat(uniqueName, @"color=green", result);
        }
コード例 #11
0
ファイル: DotGraph.cs プロジェクト: claremacrae/Pipelines
        public static StringBuilder ProcessTree(IGraphNode node, StringBuilder result,
                                                Action <IGraphNode, NodeMetadata, StringBuilder> processNode,
                                                Action <IGraphNode, IGraphNode, NodeMetadata, StringBuilder> processChild, NodeMetadata metadata)
        {
            if (metadata.IsNodeDataProcessed(node, processNode))
            {
                return(result);
            }
            metadata.SetNodeDataProcessed(node, processNode);

            processNode(node, metadata, result);

            if (node is ISender sender)
            {
                foreach (var listener in sender.Children)
                {
                    processChild(node, listener.CheckForwarding(), metadata, result);
                    ProcessTree(listener.CheckForwarding(), result, processNode, processChild, metadata);
                }
            }

            return(result);
        }
コード例 #12
0
 public static StringBuilder AppendNodeAndChildren(IGraphNode node, NodeMetadata metadata)
 {
     return(DotGraph.ProcessTree(node, new StringBuilder(), AppendFunctionalPipe, delegate { }, metadata));
 }