Exemple #1
0
            public ORCart <T> Effect(ORCart <T> crdt, object operation, DurableEvent e)
            {
                switch (operation)
                {
                case AddOp add:
                    var entry = (ORCartEntry)add.Entry;
                    return(crdt.Add((T)entry.Key, entry.Quantity, e.VectorTimestamp));

                case RemoveOp rem: return(crdt.Remove(rem.Timestamps));

                default: throw new NotSupportedException($"ORSet doesn't support [{operation.GetType().FullName}] operation.");
                }
            }
Exemple #2
0
            public object Prepare(ORCart <T> crdt, object operation)
            {
                switch (operation)
                {
                case RemoveOp rem:
                    var timestamps = crdt.PrepareRemove((T)rem.Entry);
                    if (timestamps.IsEmpty)
                    {
                        return(null);
                    }
                    else
                    {
                        return(new RemoveOp(rem.Entry, timestamps));
                    }

                default: return(operation);
                }
            }
Exemple #3
0
 public ImmutableDictionary <T, int> Value(ORCart <T> crdt) => crdt.Value;