コード例 #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;
        }
コード例 #2
0
 public bool CanMerge(IMergeJudge mergeJudge)
 {
     if (mergeJudge is ThrottleMergeJudge <T> timeStampMergeInfo)
     {
         return(Equals(Key, timeStampMergeInfo.Key) &&
                TimeStamp - timeStampMergeInfo.TimeStamp < ConvergeTimeSpan);
     }
     return(false);
 }
コード例 #3
0
        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;
        }
コード例 #5
0
 public IBuilderFromValues <T> Throttle(object key, TimeSpan timeSpan)
 {
     Debug.Assert(key != null, ErrorMessages.NotNull);
     _mergeJudge = new ThrottleMergeJudge <int>(key.GetHashCode(), timeSpan);
     return(this);
 }