internal HistoryEntry[] Select(GaugeDuration duration, DateTime currentDate) { if (!duration.IsInfinity) { if (duration.IsTimeBased) { DateTime fromDate = currentDate - duration.ToTimeSpan(); return(Select(fromDate, currentDate)); } return(Select((int)duration.Count)); } return(Select()); }
internal void Truncate(GaugeDuration d) { if (d.IsInfinity) { return; } if (d.IsEmpty) { lock (this) { Clear(); } return; } if (d.IsCountBased) { if (!((double)base.Count > d.Count)) { return; } lock (this) { while ((double)base.Count > d.Count) { RemoveAt(0); } } return; } DateTime t = Top.Timestamp - d.ToTimeSpan(); if (!(this[0].Timestamp < t)) { return; } lock (this) { while (this[0].Timestamp < t) { RemoveAt(0); } } }
internal void Extend(GaugeDuration extend, DateTime topDate, DateTime btmDate) { if (extend.IsInfinity) { DurationType = DurationType.Infinite; } else if (extend.IsCountBased && Count < extend.Count) { Count = extend.Count; } else if (extend.IsTimeBased) { DateTime t = topDate - extend.ToTimeSpan(); if (btmDate > t) { Count++; } } }