コード例 #1
0
        protected double?GetTransactionalLimitRate(DateTime limitDate, TransactionDateLimit limit)
        {
            ReaderWriterLockSlim _slimLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            _slimLock.EnterReadLock();

            double?_rate = limit.DefaultRate;

            //transactions.Where(x=> (date - x.Date).TotalDays >= 10).Where(y=> y.Type == limit.Type).First()
            foreach (var transaction in this.Transactions)
            {
                if (transaction.Type == limit.TransactionType)
                {
                    if ((limitDate - transaction.Date).TotalDays <= limit.PastDuration)
                    {
                        _rate = limit.LimitRate;
                    }
                }
            }
            if (_slimLock.IsReadLockHeld)
            {
                _slimLock.ExitReadLock();
            }
            return(_rate);
        }
コード例 #2
0
        // This is better to be exposed to the external runner. The user of the library should identify the rates rules.
        protected override void RegisterRateProviders()
        {
            IRateLimit limit = new TransactionDateLimit(TransactionType.Withdraw, 10, 0.05, 0.001);

            this.RateLimits.Add(limit);
        }