/// <summary>
 /// Gets the blip targeted by this operation, creating a data document if it does not exist.
 /// </summary>
 /// <param name="target"></param>
 /// <returns>blip targeted by this operation, never null</returns>
 private IBlipData GetTargetBlip(IWaveletData target)
 {
     return target.GetDocument(BlipId) 
         ?? target.CreateDocument(BlipId, Context.Creator,
             new Collection<ParticipantId> { Context.Creator }, 
             EmptyDocument.Empty,
             Context.Timestamp, target.Version + Context.VersionIncrement);            
 }
 protected override void DoApply(IWaveletData wavelet)
 {
     if (!(_position == EndPosition
         ? wavelet.AddParticipant(ParticipantId)
         : wavelet.AddParticipant(ParticipantId, _position)))
     {
         throw new OperationException("Attempt to add a duplicate participant");
     }
 }
        public override IList<WaveletOperation> ApplyAndReturnReverse(IWaveletData target)
        {
            var result = new ReadOnlyCollection<WaveletOperation>(new WaveletOperation[]
            {
                DoApplyInternal(target)
            });
            Update(target);

            return result;
        }
        public override IList<WaveletOperation> ApplyAndReturnReverse(IWaveletData target)
        {
            WaveletOperationContext reverseContext = CreateReverseContext(target);
            DoApply(target);
            Update(target);

            return new ReadOnlyCollection<WaveletOperation>(new WaveletOperation[]
            {
                new RemoveParticipantOperation(reverseContext, ParticipantId)
            });
        }
 public override IList<WaveletOperation> ApplyAndReturnReverse(IWaveletData target)
 {
     var blip = GetTargetBlip(target);
     var operations = BlipOp.ApplyAndReturnReverse(blip);
     var ret = new List<WaveletOperation>();
     foreach (var op in operations) 
     {
         ret.Add(new WaveletBlipOperation(BlipId, op));
     }
     Update(target);
     return ret;
 }
 private int DetermineParticipantPosition(IWaveletData target)
 {
     int position = 0;
     foreach (ParticipantId participantId in target.GetParticipants())
     {
         if (participantId.Equals(ParticipantId))
         {
             return position;
         }
         position++;
     }
     throw new OperationException(string.Format("Attempt to remove non-existent participant: {0}", ParticipantId));
 }
        private VersionUpdateOperation DoApplyInternal(IWaveletData wavelet)
        {
            HashedVersion oldHashedVersion = wavelet.HashedVersion;
            if (string.IsNullOrEmpty(_docId))
            {
                // Update blip version.
                var blip = (IBlipData) wavelet.GetDocument(_docId);
                long newWaveletVersion = wavelet.Version + Context.VersionIncrement;
                long newDocVersion = _useFixedBlipInfo ? _docVersion : newWaveletVersion;
                long oldDocVersion = blip.LastModifiedVersion = newDocVersion;

                return new VersionUpdateOperation(Context.Creator, -Context.VersionIncrement, oldHashedVersion, _docId,
                    oldDocVersion, true);
            }
            return new VersionUpdateOperation(Context.Creator, -Context.VersionIncrement, oldHashedVersion);
        }
 protected override void DoApply(IWaveletData wavelet)
 {
     var blip = GetTargetBlip(wavelet);
     BlipOp.Apply(blip);
 }
Beispiel #9
0
 public override IList<WaveletOperation> ApplyAndReturnReverse(IWaveletData target)
 {
     WaveletOperation reverse = new NoOp(CreateReverseContext(target));
     Apply(target);
     return new ReadOnlyCollection<WaveletOperation>(new[] {reverse});
 }
Beispiel #10
0
 protected override void DoApply(IWaveletData wavelet)
 {
     // do nothing.
 }
 protected override void DoApply(IWaveletData wavelet)
 {
     DoApplyInternal(wavelet);
 }
Beispiel #12
0
 public OperationTestBase()
 {
     Context = new WaveletOperationContext(Fred, ContextTimestamp, 1);
     WaveletData = A.Fake<IWaveletData>();
 }
 protected override void DoApply(IWaveletData wavelet)
 {
     if (!wavelet.RemoveParticipant(ParticipantId))
         throw new OperationException(string.Format("Attempt to delete non-existent participant: {0}",
             ParticipantId));
 }