string AppendDataForParent(IRowReceiveHierarchicalParent[] col, IRowReceiveHierarchicalParent parent, string label)
        {
            if (parent == null)
            {
                return(null);
            }
            var sb = new StringBuilder();

            if (parent.Parent == null)
            {
                var otherAttributes = OtherAttributes(parent);
                sb.AppendLine($"Node{parent.ID} [label=\"{ReplaceStringForJavascript(parent.Values[label].ToString())}\" {otherAttributes}];");
            }

            var children = col.Where(it => it.Parent == parent).ToArray();

            if (children?.Length == 0)
            {
                return(sb.ToString());
            }


            foreach (var item in children)
            {
                var otherAttributes = OtherAttributes(item);
                sb.AppendLine($"Node{item.ID} [label=\"{ReplaceStringForJavascript(item.Values[label].ToString())}\" {otherAttributes}];");
                sb.AppendLine($"Node{parent.ID} -> Node{item.ID};");
                sb.AppendLine(AppendDataForParent(col, item, label));
            }
            return(sb.ToString());
        }
Example #2
0
        IRowReceiveHierarchicalParent[]  FromSimpleTree(SimpleTree st, IRowReceiveHierarchicalParent parent)
        {
            var li = new List <IRowReceiveHierarchicalParent>();

            foreach (var node in st)
            {
                var item   = node.Key;
                var newRow = new RowReadHierarchical();
                newRow.Values.Add("Name", item.Name ?? item.GetType().Name);
                newRow.Values.Add("Type", item.GetType().Name);
                newRow.Parent = parent;
                li.Add(newRow);
                var childs = node.Childs;
                li.AddRange(FromSimpleTree(childs, newRow));

                ISend send = item as ISend;
                if (send != null)
                {
                    newRow.Values.Add("RowType", "Sender");
                    continue;
                }
                ITransform tr = item as ITransform;
                if (tr != null)
                {
                    newRow.Values.Add("RowType", "Transformer");
                    continue;
                }
                IFilter fi = item as IFilter;
                if (fi != null)
                {
                    newRow.Values.Add("RowType", "Filter");
                    continue;
                }
                IReceive r = item as IReceive;
                if (r != null)
                {
                    newRow.Values.Add("RowType", "Receiver");
                    continue;
                }
            }
            return(li.ToArray());
        }