Exemplo n.º 1
0
        static public DiffOperation Merge(DiffOperation left, DiffOperation right)
        {
            // Remove always trumps other operations
            if (right is RemoveOperation)
            {
                return(right);
            }
            if (left is RemoveOperation)
            {
                return(left);
            }

            // Change operation trumps other operations and right changes take precedent
            if (right is ChangeOperation)
            {
                return(right);
            }
            if (left is ChangeOperation)
            {
                return(left);
            }

            // Recurseively merge array and object ops
            Debug.Assert(left.GetType() == right.GetType());
            if (left is ChangeObjectOperation)
            {
                return(ChangeObjectOperation.Merge(left as ChangeObjectOperation, right as ChangeObjectOperation));
            }
            if (left is ChangePositionArrayOperation)
            {
                return(ChangePositionArrayOperation.Merge(left as ChangePositionArrayOperation, right as ChangePositionArrayOperation));
            }
            if (left is ChangeIdArrayOperation)
            {
                return(ChangeIdArrayOperation.Merge(left as ChangeIdArrayOperation, right as ChangeIdArrayOperation));
            }

            Debug.Assert(false);
            return(null);
        }
Exemplo n.º 2
0
 public static ChangePositionArrayOperation Merge(ChangePositionArrayOperation left, ChangePositionArrayOperation right)
 {
     return(new ChangePositionArrayOperation(ListDiff.Merge(left.Diff, right.Diff)));
 }
Exemplo n.º 3
0
 public static ChangePositionArrayOperation Merge(ChangePositionArrayOperation left, ChangePositionArrayOperation right)
 {
     return new ChangePositionArrayOperation(ListDiff.Merge(left.Diff, right.Diff));
 }