コード例 #1
0
        public object Visit(ViewerNode node)
        {
            string name   = (node.Content ?? node).ToString() + idGen.ToString();
            var    parent = new NodeModel()
            {
                ID          = idGen++,
                Data        = name,
                Type        = node.Type,
                Connections = new List <int>(),
            };

            Context.Nodes.Add(parent.ID, parent);
            if (node.Children != null)
            {
                foreach (Node nodeChild in node.Children)
                {
                    ViewerNode viewerNode;
                    if (nodeChild is ViewerNode)
                    {
                        viewerNode = nodeChild as ViewerNode;
                    }
                    else
                    {
                        viewerNode = new ViewerNode(nodeChild);
                    }
                    var child = Visit(viewerNode) as NodeModel;
                    parent.Connections.Add(child.ID);
                }
            }
            return(parent);
        }
コード例 #2
0
        public object Visit(Node node)
        {
            var result = new ViewerNode(node);

            foreach (var child in node.Children)
            {
                result.Children.Add((Node)child.AcceptVisitor(this));
            }
            return(result);
        }
コード例 #3
0
 object IViewerVisitor.Visit(ViewerNode node)
 {
     return(Visit((Node)node));
 }