Beispiel #1
0
        public bool PrependNode(Node node)
        {
            if (!(((parent_ != null) && (parent_.type_ != null)) && (node.type_ != null)))
            {
                return(false);
            }
            Node nextSibling = this.nextSibling;
            Node prevSibling = this.prevSibling;

            Node parent = this.parent_;

            node.level = parent.level + 1;

            if (prevSibling == null)
            {
                node.childIndex   = 0;
                node.prevSibling  = null;
                node.nextSibling  = this;
                node.parent_      = parent;
                parent.firstChild = node;
                this.prevSibling  = node;
                childIndex++;
                while (nextSibling != null)
                {
                    nextSibling.childIndex++;
                    nextSibling = nextSibling.nextSibling;
                }
            }
            else
            {
                node.childIndex         = prevSibling.childIndex + 1;
                node.prevSibling        = prevSibling;
                node.nextSibling        = this;
                node.parent_            = parent;
                prevSibling.nextSibling = node;
                this.prevSibling        = node;
                childIndex++;
                while (nextSibling != null)
                {
                    nextSibling.childIndex++;
                    nextSibling = nextSibling.nextSibling;
                }
            }
            if (((prevSibling != null) && prevSibling.HasStyleClass()) && (prevSibling.StyleClass.Length > 0))
            {
                node.StyleClass = prevSibling.StyleClass;
            }
            node.EmbraceParent();
            parent.numChildren++;
            return(true);
        }