Exemple #1
0
 private void CompareNodeChildren(IModelObject original, IModelObject @new, IList <ObjectRepositoryEntryChanges> changes, Stack <string> stack, ChildPropertyInfo childProperty)
 {
     using (var enumerator = new TwoSequenceEnumerator <IModelObject>(
                childProperty.Accessor(original),
                childProperty.Accessor(@new)))
     {
         while (!enumerator.BothCompleted)
         {
             CompareNodeChildren(changes, stack, enumerator);
         }
     }
 }
Exemple #2
0
        private void CompareNodeChildren(IList <ObjectRepositoryEntryChanges> changes, Stack <string> stack, TwoSequenceEnumerator <IModelObject> enumerator)
        {
            if (enumerator.NodeIsStillThere)
            {
                stack.Push(enumerator.Left.Id.ToString());
                CompareNode(enumerator.Left, enumerator.Right, changes, stack);
                stack.Pop();

                enumerator.MoveNextLeft();
                enumerator.MoveNextRight();
                return;
            }
            else if (enumerator.NodeHasBeenAdded)
            {
                stack.Push(enumerator.Right.Id.ToString());
                AddNodeRecursively(enumerator.Right, changes, stack, (p, n) => new ObjectRepositoryEntryChanges(p, ChangeKind.Added, @new: n));
                stack.Pop();
                enumerator.MoveNextRight();
                return;
            }
            else if (enumerator.NodeHasBeenRemoved)
            {
                stack.Push(enumerator.Left.Id.ToString());
                AddNodeRecursively(enumerator.Left, changes, stack, (p, n) => new ObjectRepositoryEntryChanges(p, ChangeKind.Deleted, old: n));
                stack.Pop();
                enumerator.MoveNextLeft();
                return;
            }
            throw new NotSupportedException("Unexpected child changes.");
        }