Exemplo n.º 1
0
        public static NodeVm ToNodeVm(this Node parent)
        {
            // self
            var self = new NodeVm(parent);

            // top
            self.ParentNode = parent.ParentNode;

            // children
            VisitNextNodeVm(self, parent.Children);

            return(self);
        }
Exemplo n.º 2
0
        static void VisitNextNodeVm(NodeVm parentNode, IEnumerable <INode> childeren)
        {
            foreach (var child in childeren)
            {
                var self = new NodeVm(child)
                {
                    ParentNode = parentNode
                };
                parentNode.Children.Add(self);

                VisitNextNodeVm(self, child.Children);
            }
        }
Exemplo n.º 3
0
        public static Node BackToNode(this NodeVm parent)
        {
            // self
            var self = new Node()
            {
                Id = parent.Id, Name = parent.Name, NodeTypeId = parent.NodeTypeId
            };

            // top
            self.ParentNode = parent.ParentNode;

            // children
            VisitNextNodeVm(self, parent.Children);

            return(self);
        }