/// <summary> /// Removes a node from a list or block list. /// </summary> /// <param name="operation">Details of the operation performed.</param> public virtual void Remove(IWriteableRemoveNodeOperation operation) { Debug.Assert(operation != null); int RemoveIndex = operation.Index; Debug.Assert(RemoveIndex >= 0 && RemoveIndex < StateList.Count); IWriteablePlaceholderNodeState OldChildState = StateList[RemoveIndex]; RemoveFromStateList(RemoveIndex); INode ParentNode = Owner.Node; NodeTreeHelperList.RemoveFromList(ParentNode, PropertyName, RemoveIndex); while (RemoveIndex < StateList.Count) { IWriteablePlaceholderNodeState State = StateList[RemoveIndex]; IWriteableBrowsingListNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingListNodeIndex; Debug.Assert(NodeIndex != null); Debug.Assert(NodeIndex.Index == RemoveIndex + 1); NodeIndex.MoveDown(); RemoveIndex++; } operation.Update(OldChildState); }
/// <summary> /// Removes a node from a block list. This method is not allowed to remove the last node of a block. /// </summary> /// <param name="operation">Details of the operation performed.</param> public virtual void Remove(IWriteableRemoveNodeOperation operation) { Debug.Assert(operation != null); // Only the safe case where the block isn't removed is allowed for this version of Remove(). Remove(null, operation, operation.BlockIndex, operation.Index); }
/// <summary> /// Handler called every time a state is removed from the controller. /// </summary> /// <param name="operation">Details of the operation performed.</param> private protected virtual void OnStateRemoved(IWriteableRemoveNodeOperation operation) { Debug.Assert(operation != null); IWriteablePlaceholderNodeState RemovedState = operation.RemovedState; Debug.Assert(RemovedState != null); Debug.Assert(!StateViewTable.ContainsKey(RemovedState)); }
private protected virtual void Remove(IWriteableRemoveBlockOperation blockOperation, IWriteableRemoveNodeOperation nodeOperation, int blockIndex, int index) { Debug.Assert(blockIndex >= 0 && blockIndex < BlockStateList.Count); IWriteableBlockState BlockState = BlockStateList[blockIndex]; Debug.Assert(index >= 0 && index < BlockState.StateList.Count); IBlock ChildBlock = BlockState.ChildBlock; INode ParentNode = Owner.Node; int i; IWriteablePlaceholderNodeState OldChildState = BlockState.StateList[index]; INode RemovedNode = OldChildState.Node; BlockState.Remove((IWriteableBrowsingBlockNodeIndex)OldChildState.ParentIndex, index); NodeTreeHelperBlockList.RemoveFromBlock(ParentNode, PropertyName, blockIndex, index, out bool IsBlockRemoved); if (IsBlockRemoved) { Debug.Assert(blockOperation != null); RemoveFromBlockStateList(blockIndex); blockOperation.Update(BlockState, OldChildState); for (i = blockIndex; i < BlockStateList.Count; i++) { IWriteableBlockState NextBlockState = BlockStateList[i]; foreach (IWriteablePlaceholderNodeState State in NextBlockState.StateList) { IWriteableBrowsingExistingBlockNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(NodeIndex != null); Debug.Assert(NodeIndex.BlockIndex == i + 1); NodeIndex.MoveBlockDown(); } } } else { Debug.Assert(nodeOperation != null); nodeOperation.Update(OldChildState); } i = index; while (i < BlockState.StateList.Count) { IWriteablePlaceholderNodeState State = BlockState.StateList[i]; IWriteableBrowsingExistingBlockNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(NodeIndex != null); Debug.Assert(NodeIndex.BlockIndex == blockIndex); Debug.Assert(NodeIndex.Index == i + 1); NodeIndex.MoveDown(); i++; } }
/// <summary> /// Removes a node from a list or block list. /// </summary> /// <param name="operation">Details of the operation performed.</param> public abstract void Remove(IWriteableRemoveNodeOperation operation);