Ejemplo n.º 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.");
                }
            }
Ejemplo n.º 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);
                }
            }
Ejemplo n.º 3
0
 public ImmutableDictionary <T, int> Value(ORCart <T> crdt) => crdt.Value;