Exemplo n.º 1
0
 public OtOperation(IEnumerable <OtChange> changes, RdChangeOrigin origin, int timestamp, OtOperationKind kind)
 {
     Origin    = origin;
     Timestamp = timestamp;
     Kind      = kind;
     Changes   = Normalize(changes); // todo eliminate for deserialization
 }
Exemplo n.º 2
0
Arquivo: RdAck.cs Projeto: epeshk/rd
 //private fields
 //primary constructor
 public RdAck(
     int timestamp,
     RdChangeOrigin origin
     )
 {
     Timestamp = timestamp;
     Origin    = origin;
 }
Exemplo n.º 3
0
        public RdTextBuffer(RdTextBufferState state) : base(state)
        {
            myTextChanged = new ViewableProperty <RdTextChange>();
            myChangesToConfirmOrRollback = new List <RdTextBufferChange>();
            BufferVersion = TextBufferVersion.InitVersion;
            myLocalOrigin = IsMaster ? RdChangeOrigin.Master : RdChangeOrigin.Slave;

            // disabling mastering, text buffer must resolve conflicts by itself
            ((RdProperty <RdTextBufferChange>)Delegate.Changes).IsMaster = false;
        }
Exemplo n.º 4
0
        public static OtOperation ToOperation(this RdTextChange textChange, RdChangeOrigin origin, int ts)
        {
            var changes = new List <OtChange>();

            changes.Add(new Retain(textChange.StartOffset));
            switch (textChange.Kind)
            {
            case RdTextChangeKind.Insert:
                changes.Add(new InsertText(textChange.New));
                break;

            case RdTextChangeKind.Remove:
                changes.Add(new DeleteText(textChange.Old));
                break;

            case RdTextChangeKind.Replace:
            {
                changes.Add(new InsertText(textChange.New));
                changes.Add(new DeleteText(textChange.Old));
                break;
            }

            case RdTextChangeKind.Reset:
                changes.Add(new InsertText(textChange.New));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var currentOffset = changes.Sum(x => x.GetTextLengthAfter());

            changes.Add(new Retain(textChange.FullTextLength - currentOffset));

            var kind      = textChange.Kind == RdTextChangeKind.Reset ? OtOperationKind.Reset : OtOperationKind.Normal;
            var operation = new OtOperation(changes, origin, ts, kind);

            Assertion.Assert(operation.DocumentLengthAfter() == textChange.FullTextLength,
                             "operation.DocumentLengthAfter() == textChange.FullTextLength");
            return(operation);
        }
Exemplo n.º 5
0
 public TextBufferCommand(RdTextChange change, RdChangeOrigin origin, bool deliverImmediately)
 {
     Change             = change;
     Origin             = origin;
     DeliverImmediately = deliverImmediately;
 }
Exemplo n.º 6
0
 public RdTextBufferChange(TextBufferVersion version, RdChangeOrigin origin, RdTextChange change)
 {
     Change  = change;
     Version = version;
     Origin  = origin;
 }