Ejemplo n.º 1
0
        private protected virtual void CloneChildren(INode parentNode, IBlock parentBlock)
        {
            for (int i = 0; i < StateList.Count; i++)
            {
                IReadOnlyPlaceholderNodeState ChildState = StateList[i];

                INode ChildNodeClone = ChildState.CloneNode();
                Debug.Assert(ChildNodeClone != null);

                NodeTreeHelperBlockList.InsertIntoBlock(parentBlock, i, ChildNodeClone);
            }
        }
        /// <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);
            }
        }
        public static void ReadOnlyClone()
        {
            ControllerTools.ResetExpectedName();

            Main RootNode = CreateRoot(ValueGuid0, Imperfections.None);

            IReadOnlyRootNodeIndex RootIndex = new ReadOnlyRootNodeIndex(RootNode);

            Assert.That(RootIndex != null);

            ReadOnlyController Controller = ReadOnlyController.Create(RootIndex);

            Assert.That(Controller != null);

            IReadOnlyPlaceholderNodeState RootState = Controller.RootState;

            Assert.That(RootState != null);

            BaseNode.Node ClonedNode = RootState.CloneNode();
            Assert.That(BaseNodeHelper.NodeTreeDiagnostic.IsValid(ClonedNode));

            IReadOnlyRootNodeIndex CloneRootIndex = new ReadOnlyRootNodeIndex(ClonedNode);

            Assert.That(CloneRootIndex != null);

            ReadOnlyController CloneController = ReadOnlyController.Create(CloneRootIndex);

            Assert.That(CloneController != null);

            IReadOnlyPlaceholderNodeState CloneRootState = Controller.RootState;

            Assert.That(CloneRootState != null);

            ReadOnlyNodeStateReadOnlyList AllChildren      = RootState.GetAllChildren();
            ReadOnlyNodeStateReadOnlyList CloneAllChildren = CloneRootState.GetAllChildren();

            Assert.That(AllChildren.Count == CloneAllChildren.Count);
        }