private long?GetLimiterCount(TimeSpan span) { Limiter item = Limiters.FirstOrDefault(l => l.Period == span); long? result = null; if (item != null) { result = item.Count; } return(result); }
private void SetLimiter(TimeSpan span, long?count) { Limiter item = Limiters.FirstOrDefault(l => l.Period == span); if (item != null) { _limits.Remove(item); } if (!count.HasValue) { return; } item = new Limiter { Count = count.Value, Period = span }; _limits.Add(item); }