public CountTracker(ICountTrackerConfig config, ICountTrackerDiagnostics <TEntityType, TCountType> perfCounters, Trace tracer, Func <DateTime> timeProvider) { if (!typeof(TEntityType).IsEnum) { throw new ArgumentException("TEntityType must be an enum"); } if (!typeof(TCountType).IsEnum) { throw new ArgumentException("TCountType must be an enum"); } if (typeof(TEntityType).IsDefined(typeof(FlagsAttribute), false)) { throw new ArgumentException("TEntityType cannot be a flags enum"); } if (typeof(TCountType).IsDefined(typeof(FlagsAttribute), false)) { throw new ArgumentException("TCountType cannot be a flags enum"); } ArgumentValidator.ThrowIfNull("config", config); ArgumentValidator.ThrowIfNull("perfCounters", perfCounters); ArgumentValidator.ThrowIfNull("tracer", tracer); ArgumentValidator.ThrowIfNull("timeProvider", timeProvider); this.config = config; this.perfCounters = perfCounters; this.tracer = tracer; this.timeProvider = timeProvider; this.lastUnpromotedEmptiedTime = this.timeProvider(); this.timer = new GuardedTimer(new TimerCallback(this.TimerCallback), null, TimeSpan.FromSeconds(5.0)); }
public CountTracker(ICountTrackerConfig config, ICountTrackerDiagnostics <TEntityType, TCountType> perfCounters, Trace tracer) : this(config, perfCounters, tracer, () => DateTime.UtcNow) { }