Esempio n. 1
0
        static DateTimeOffset GetNextTimeOfDay(this ITopicScheduler scheduler, TimeSpan timeOfDay)
        {
            var now   = scheduler.Now;
            var today = now.Date;

            var whenToday = today + timeOfDay;

            return(whenToday > now ? whenToday : today.AddDays(1) + timeOfDay);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        //
        // Interval
        //

        public static void NextInterval(this ITopicScheduler scheduler, Event e, TimeSpan interval) =>
        scheduler.NextInterval(e, interval, TimeSpan.Zero);
Esempio n. 5
0
 public static void NextTimeOfDay(this ITopicScheduler scheduler, Event e, params TimeSpan[] timesOfDay) =>
 scheduler.NextTimeOfDay(e, timesOfDay as IEnumerable <TimeSpan>);
Esempio n. 6
0
 public static void NextTimeOfDay(this ITopicScheduler scheduler, Event e, TimeSpan timeOfDay) =>
 scheduler.At(e, scheduler.GetNextTimeOfDay(timeOfDay));