Пример #1
0
        /// <summary>
        /// Inserts a new node in a list.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        public virtual void Insert(WriteableInsertNodeOperation operation)
        {
            int InsertionIndex = operation.Index;

            Debug.Assert(InsertionIndex >= 0 && InsertionIndex <= StateList.Count);

            Node ParentNode = Owner.Node;
            Node Node       = operation.Node;

            NodeTreeHelperList.InsertIntoList(ParentNode, PropertyName, InsertionIndex, Node);

            IWriteableBrowsingListNodeIndex BrowsingIndex = CreateBrowsingNodeIndex(Node, InsertionIndex);
            IWriteablePlaceholderNodeState  ChildState    = (IWriteablePlaceholderNodeState)CreateNodeState(BrowsingIndex);

            InsertInStateList(InsertionIndex, ChildState);

            operation.Update(BrowsingIndex, ChildState);

            while (++InsertionIndex < StateList.Count)
            {
                IWriteablePlaceholderNodeState State = (IWriteablePlaceholderNodeState)StateList[InsertionIndex];

                IWriteableBrowsingListNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingListNodeIndex;
                Debug.Assert(NodeIndex != null);
                Debug.Assert(NodeIndex.Index == InsertionIndex - 1);

                NodeIndex.MoveUp();
            }
        }
        /// <inheritdoc/>
        public override void CloneChildren(Node parentNode)
        {
            NodeTreeHelperList.ClearChildNodeList(parentNode, PropertyName);

            for (int i = 0; i < StateList.Count; i++)
            {
                IReadOnlyPlaceholderNodeState ChildState = StateList[i];

                // Clone all children recursively.
                Node ChildNodeClone = ChildState.CloneNode();
                Debug.Assert(ChildNodeClone != null);

                NodeTreeHelperList.InsertIntoList(parentNode, PropertyName, i, ChildNodeClone);
            }
        }