public ExpirationCalculation(DateTimeOffset initail, TimeSpan slidingSize, DateTimeOffset maxExpireDate)
 {
     IsNegativeSlidingSize(slidingSize);
     createDate         = DateTimeOffset.Now;
     this.slidingSize   = slidingSize;
     this.initail       = initail;
     this.maxExpireDate = maxExpireDate;
     expireInfo         = new Effective(initail);
     mode = ExpirationMode.Sliding;
 }
 public ExpirationCalculation(DateTimeOffset initail)
 {
     maxCount      = 0;
     createDate    = DateTime.Now;
     slidingSize   = TimeSpan.Zero;
     this.initail  = initail;
     maxExpireDate = initail;
     expireInfo    = new Effective(initail);
     mode          = ExpirationMode.Absolute;
 }
        public bool CheckExpire(DateTimeOffset date, out Effective effective)
        {
            var isExpire = expireInfo.expireDate <= date ? true : false;

            effective = new Effective(expireInfo.expireDate);
            if (!isExpire)
            {
                effective.expireDate = expireInfo.expireDate >= maxExpireDate ? maxExpireDate.Value : expireInfo.expireDate.Add(slidingSize);
            }
            return(isExpire);
        }
 public ExpirationCalculation(DateTimeOffset initail, TimeSpan slidingSize, uint maxCount = 0)
 {
     IsNegativeSlidingSize(slidingSize);
     this.maxCount    = maxCount;
     createDate       = DateTime.Now;
     this.slidingSize = slidingSize;
     this.initail     = initail;
     maxExpireDate    = maxCount != 0 ? initail.Add(new TimeSpan(slidingSize.Ticks * maxCount)) : maxExpireDate;
     expireInfo       = new Effective(initail);
     mode             = ExpirationMode.Sliding;
 }
 public bool CheckExpire(out Effective expiration)
 {
     return(CheckExpire(DateTimeOffset.Now, out expiration));
 }