Пример #1
0
            public override IReplicatedData Merge(IReplicatedData other)
            {
                switch (other)
                {
                case AddDeltaOperation operation:
                {
                    var u = operation.Underlying;
                    // Note that we only merge deltas originating from the same node
                    return(new AddDeltaOperation(new ORSet <T>(
                                                     ConcatElementsMap(u.ElementsMap),
                                                     Underlying.VersionVector.Merge(u.VersionVector))));
                }

                case AtomicDeltaOperation _:
                    return(new DeltaGroup(ImmutableArray.Create(this, other)));

                case DeltaGroup dg:
                {
                    var vector = dg.Operations;
                    return(new DeltaGroup(vector.Add(this)));
                }

                default:
                    throw new ArgumentException($"Unknown delta operation of type {other.GetType()}", nameof(other));
                }
            }
Пример #2
0
 public override IReplicatedData Merge(IReplicatedData other)
 {
     if (other is AtomicDeltaOperation)
     {
         return(new DeltaGroup(ImmutableArray.Create(this, other)));
     }
     else if (other is DeltaGroup)
     {
         var vector = ((DeltaGroup)other).Operations;
         return(new DeltaGroup(vector.Add(this)));
     }
     else
     {
         throw new ArgumentException($"Unknown delta operation of type {other.GetType()}", nameof(other));
     }
 }
Пример #3
0
 public override IReplicatedData Merge(IReplicatedData other)
 {
     if (other is AddDeltaOperation)
     {
         var u = ((AddDeltaOperation)other).Underlying;
         // Note that we only merge deltas originating from the same node
         return(new AddDeltaOperation(new ORSet <T>(
                                          ConcatElementsMap(u.ElementsMap),
                                          Underlying.VersionVector.Merge(u.VersionVector))));
     }
     else if (other is AtomicDeltaOperation)
     {
         return(new DeltaGroup(ImmutableArray.Create(this, other)));
     }
     else if (other is DeltaGroup)
     {
         var vector = ((DeltaGroup)other).Operations;
         return(new DeltaGroup(vector.Add(this)));
     }
     else
     {
         throw new ArgumentException($"Unknown delta operation of type {other.GetType()}", nameof(other));
     }
 }