Exemplo n.º 1
0
		public Usage()
		{
			this.syncObject = new object();
			this.concurrentRequestQuotaViolationsPerSec = new PerSecCounter();
			PerSecCounter perSecCounter = this.concurrentRequestQuotaViolationsPerSec;
			perSecCounter.PreResetEventHandler += (object src, PerTimeslotCounter.PreResetEventArgs args) => {
				DateTime time = args.Time;
				TraceHelper.Current.ConcurrentRequestQuotaViolationCount(args.Counter, time.ToString(CultureInfo.CurrentCulture));
			}
			;
			this.requests = new PerTimeslotCounter(30);
			this.requestPerSecQuotaViolations = new PerSecCounter();
			PerSecCounter perSecCounter1 = this.requestPerSecQuotaViolations;
			perSecCounter1.PreResetEventHandler += (object src, PerTimeslotCounter.PreResetEventArgs args) => {
				DateTime time = args.Time;
				TraceHelper.Current.RequestPerSecondQuotaViolationCount(args.Counter, time.ToString(CultureInfo.CurrentCulture));
			}
			;
		}
Exemplo n.º 2
0
        public virtual void Increment(int newTimeSlot)
        {
            DateTime now = DateTimeHelper.Now;

            if (newTimeSlot != this.timeSlotWindow.TimeSlot.Value || !this.timeSlotWindow.InsideWindow(now))
            {
                if (this.PreResetEventHandler != null && this.@value != 0)
                {
                    this.PreResetEventHandler(this, new PerTimeslotCounter.PreResetEventArgs(this.timeSlotWindow.BaseTime, this.@value, this.timeSlotWindow.TimeSlot.Value, newTimeSlot));
                }
                this.@value = 1;
                this.timeSlotWindow.Set(now, newTimeSlot);
                return;
            }
            else
            {
                PerTimeslotCounter perTimeslotCounter = this;
                perTimeslotCounter.@value = perTimeslotCounter.@value + 1;
                return;
            }
        }