private void FilterAndAddReading(ReadingFromSensor reading) { if (ReadingFromCheckedLocation(reading) && IsNotDuplicate(reading)) { Readings.Add(reading); Console.WriteLine("Collected reading."); } else { Console.WriteLine("Found reading from an unchecked sensor."); } }
private void RemoveOneExpiredReading(ReadingFromSensor reading) { if (Readings.Count == 0) { return; } var first = Readings.FirstOrDefault(r => r.Timestamp < reading.Timestamp - _expiryTime); if (first != null) { Readings.Remove(first); } }
private void RemoveOneExpiredReading(ReadingFromSensor reading) { var currentTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); if (Readings.Count == 0) { return; } var first = Readings.FirstOrDefault(r => r.Timestamp < currentTimestamp - _expiryTime); if (first != null) { Readings.Remove(first); } }
private bool IsNotDuplicate(ReadingFromSensor reading) { return(!Readings.Contains(reading)); }
private bool ReadingFromCheckedLocation(ReadingFromSensor reading) { return(_locationIds.Contains(reading.LocationId)); }