public static void NextTimeOfDay(this ITopicScheduler scheduler, Event e, IEnumerable <TimeSpan> timesOfDay) { var whenOccurs = timesOfDay .Select(scheduler.GetNextTimeOfDay) .DefaultIfEmpty(DateTimeOffset.MinValue) .Min(); Expect.True(whenOccurs > DateTimeOffset.MinValue, "Scheduling requires at least one time of day"); scheduler.At(e, whenOccurs); }
public static void NextInterval(this ITopicScheduler scheduler, Event e, TimeSpan interval, TimeSpan offset) { Expect.That(interval).IsGreaterThan(TimeSpan.Zero, "Scheduling requires an interval in the future"); var now = scheduler.Now; var today = now.Date; var whenOccursNext = today + offset; while (whenOccursNext < now) { whenOccursNext += interval; } var whenOccurs = whenOccursNext.Date == now.Date ? whenOccursNext : now.Date.AddDays(1) + offset; scheduler.At(e, whenOccurs); }
public static void NextTimeOfDay(this ITopicScheduler scheduler, Event e, TimeSpan timeOfDay) => scheduler.At(e, scheduler.GetNextTimeOfDay(timeOfDay));