예제 #1
0
        public MergeableOperation(NamedAction invoke, NamedAction rollback, IMergeJudge mergeJudge = null)
        {
            Debug.Assert(invoke != null);
            Debug.Assert(rollback != null);
            _rollForward = invoke;
            _rollBack    = rollback;

            MergeJudge = mergeJudge;
        }
 public bool CanMerge(IMergeJudge mergeJudge)
 {
     if (mergeJudge is ThrottleMergeJudge <T> timeStampMergeInfo)
     {
         return(Equals(Key, timeStampMergeInfo.Key) &&
                TimeStamp - timeStampMergeInfo.TimeStamp < ConvergeTimeSpan);
     }
     return(false);
 }
        public IMergeJudge Update(IMergeJudge prevMergeJudge)
        {
            if (prevMergeJudge is ThrottleMergeJudge <T> throttleMergeJudge)
            {
                throttleMergeJudge.TimeStamp = DateTime.Now;
                return(throttleMergeJudge);
            }

            return(this);
        }
예제 #4
0
        public MergeableOperation(Action invoke, Action rollback, IMergeJudge mergeJudge = null)
        {
            Debug.Assert(invoke != null);
            Debug.Assert(rollback != null);
            _rollForward = new NamedAction()
            {
                Action = invoke
            };
            _rollBack = new NamedAction()
            {
                Action = rollback
            };

            MergeJudge = mergeJudge;
        }
 public IBuilderFromValues <T> Throttle(object key, TimeSpan timeSpan)
 {
     Debug.Assert(key != null, ErrorMessages.NotNull);
     _mergeJudge = new ThrottleMergeJudge <int>(key.GetHashCode(), timeSpan);
     return(this);
 }