/// <summary>
        /// Builds a HourlyScheduleProvider
        /// </summary>
        /// <param name="schedule">Any implementation of <see cref="IScheduleProvider"/> object</param>
        /// <returns>An instantiated <see cref="HourlyScheduleProvider"/> object</returns>
        private static IScheduleProvider BuildHourlyScheduleProvider(IScheduleParameters schedule)
        {
            var startTime  = DateTime.Parse(schedule.StartTime);
            var timesToRun = schedule.TimeParameters.Select(TimeSpan.Parse);

            return(new HourlyScheduleProvider(startTime, new CurrentClock(), timesToRun));
        }
        /// <summary>
        /// Builds a IntervalScheduleProvider
        /// </summary>
        /// <param name="schedule">Any implementation of <see cref="IScheduleProvider"/> object</param>
        /// <returns>An instantiated <see cref="IntervalScheduleProvider"/> object</returns>
        private static IScheduleProvider BuildIntervalScheduleProvider(IScheduleParameters schedule)
        {
            var startTime = DateTime.Parse(schedule.StartTime);
            var interval  = TimeSpan.Parse(schedule.TimeParameters.First());

            return(new IntervalScheduleProvider(startTime, new CurrentClock(), interval));
        }
        /// <summary>
        /// Builds a WeeklyScheduleProvider
        /// </summary>
        /// <param name="schedule">Any implementation of <see cref="IScheduleProvider"/> object</param>
        /// <returns>An instantiated <see cref="WeeklyScheduleProvider"/> object</returns>
        private static IScheduleProvider BuildWeeklyScheduleProvider(IScheduleParameters schedule)
        {
            var startTime  = DateTime.Parse(schedule.StartTime);
            var daysOfWeek = schedule.TimeParameters.Select(x => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), x));

            return(new WeeklyScheduleProvider(startTime, new CurrentClock(), daysOfWeek));
        }
        public static IScheduleProvider Build(IScheduleParameters schedule)
        {
            IScheduleProvider result;

            switch (schedule.Frequency)
            {
            case "Monthly":
                result = BuildMonthlyScheduleProvider(schedule);
                break;

            case "Daily":
                result = BuildDailyScheduleProvider(schedule);
                break;

            case "Hourly":
                result = BuildHourlyScheduleProvider(schedule);
                break;

            case "Interval":
                result = BuildIntervalScheduleProvider(schedule);
                break;

            case "Weekly":
                result = BuildWeeklyScheduleProvider(schedule);
                break;

            default:
                throw new ScheduleProviderException(schedule.Frequency);
            }
            return(result);
        }
        /// <summary>
        /// Builds a MonthlyScheduleProvider
        /// </summary>
        /// <param name="schedule">Any implementation of <see cref="IScheduleProvider"/> object</param>
        /// <returns>An instantiated <see cref="MonthlyScheduleProvider"/> object</returns>
        private static IScheduleProvider BuildMonthlyScheduleProvider(IScheduleParameters schedule)
        {
            var startTime = DateTime.Parse(schedule.StartTime);
            var daysToRun = schedule.TimeParameters.Select(int.Parse);

            return(new MonthlyScheduleProvider(startTime, new CurrentClock(), daysToRun));
        }
 /// <summary>
 /// Builds a DailyScheduleProvider
 /// </summary>
 /// <param name="schedule">Any implementation of <see cref="IScheduleProvider"/> object</param>
 /// <returns>An instantiated <see cref="DailyScheduleProvider"/> object</returns>
 private static IScheduleProvider BuildDailyScheduleProvider(IScheduleParameters schedule)
 {
     return(new DailyScheduleProvider(DateTime.Parse(schedule.StartTime), new CurrentClock()));
 }