public TwentyFourSevenTimer(TwentyFourSevenTimerConfig config, INow time) { myTimeReference = time; myConfig = config; Alarms = ParseConfig(); LastAlarmTriggered = myTimeReference.Now(); }
/// <summary> /// /// </summary> /// <param name="grace">Not sure I want to use/expose this yet</param> /// <returns></returns> private IEnumerable <DateTime> Triggered(TimeSpan grace) { var now = myTimeReference.Now(); var triggered = (from alarmTime in Alarms[now.DayOfWeek] let dtAlarm = (new DateTime(now.Year, now.Month, now.Day) + alarmTime) where (dtAlarm > LastAlarmTriggered) && (dtAlarm <= now) orderby dtAlarm.TimeOfDay descending select dtAlarm).ToList(); if (triggered.Count > 0) { LastAlarmTriggered = triggered.First(); } return(triggered); }