예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DailyRecurrence"/> class
        /// executed daily on the specified <paramref name="weekDays"/>
        /// at the specified <paramref name="timesOfDay"/>.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="weekDays">The recurrent week days (ex: every <see cref="RecurrentWeekDays.WeekEnd"/>).</param>
        /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
        /// -or- <paramref name="weekDays"/> is not specified
        /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">One of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
        public DailyRecurrence(RecurrenceBehavior behavior, RecurrentWeekDays weekDays, IEnumerable <TimeSpan> timesOfDay)
            : base(behavior, timesOfDay)
        {
            if (weekDays == default(RecurrentWeekDays))
            {
                throw new ArgumentException("Non specified argument.", "weekDays");
            }

            WeekDays = weekDays;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PeriodRecurrence"/> class.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="period">The time interval between each occurrence.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="period"/> is not strictly positive.</exception>
        public PeriodRecurrence(RecurrenceBehavior behavior, TimeSpan period)
            : base(behavior)
        {
            if (period <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("period");
            }

            Period = period;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WeeklyRecurrence"/> class
        /// executed every <paramref name="weeks"/>(s)
        /// on the specified <paramref name="weekDays"/>
        /// at the specified <paramref name="timesOfDay"/>.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="weekDays">The recurrent week days (ex: every <see cref="RecurrentWeekDays.WeekEnd"/>).</param>
        /// <param name="weeks">The recurrent week(s) (ex: every 2 weeks).</param>
        /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
        /// -or- <paramref name="weekDays"/> is not specified
        /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="weeks"/> is not strictly positive
        /// -or- one of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
        public WeeklyRecurrence(RecurrenceBehavior behavior, RecurrentWeekDays weekDays, int weeks, IEnumerable <TimeSpan> timesOfDay)
            : base(behavior, timesOfDay)
        {
            if (weekDays == default(RecurrentWeekDays))
            {
                throw new ArgumentException("Non specified argument.", "weekDays");
            }

            if (weeks <= 0)
            {
                throw new ArgumentOutOfRangeException("weeks");
            }

            WeekDays = weekDays;
            Weeks    = weeks;
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MonthlyRecurrence"/> class
        /// executed every <paramref name="weekDayOfMonth"/> of the specified <paramref name="months"/>
        /// at the specified <paramref name="timesOfDay"/>.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="weekDayOfMonth">The recurrent week day of month.</param>
        /// <param name="months">The recurrent months.</param>
        /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
        /// -or- <paramref name="weekDayOfMonth"/> is not specified
        /// -or- <paramref name="months"/> is not specified
        /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">One of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
        public MonthlyRecurrence(RecurrenceBehavior behavior, RecurrentWeekDaysOfMonth weekDayOfMonth, RecurrentMonths months, IEnumerable <TimeSpan> timesOfDay)
            : base(behavior, timesOfDay)
        {
            if (weekDayOfMonth == default(RecurrentWeekDaysOfMonth))
            {
                throw new ArgumentException("Non specified argument.", "weekDayOfMonth");
            }

            if (months == default(RecurrentMonths))
            {
                throw new ArgumentException("Non specified argument.", "months");
            }


            WeekDaysOfMonth = weekDayOfMonth;
            Months          = months;
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CalendarRecurrence"/> class.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
        /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">One of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
        protected internal CalendarRecurrence(RecurrenceBehavior behavior, IEnumerable <TimeSpan> timesOfDay)
            : base(behavior)
        {
            if (timesOfDay == null || timesOfDay.Count() == 0)
            {
                throw new ArgumentException("timesOfDay");
            }

            var outOfRanges = from timeOfDay in timesOfDay
                              where timeOfDay < TimeSpan.Zero || timeOfDay >= TimeSpan.FromDays(1)
                              select timeOfDay;

            if (outOfRanges.Count() != 0)
            {
                throw new ArgumentOutOfRangeException("timesOfDay", string.Format("Out of range times of day: {0}", string.Join(",", outOfRanges)));
            }

            TimesOfDay = timesOfDay.Distinct().OrderBy(timeOfDay => timeOfDay).ToList();
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MonthlyRecurrence"/> class
        /// executed every <paramref name="dayOfMonth"/> of the specified <paramref name="months"/>
        /// at the specified <paramref name="timesOfDay"/>.
        /// </summary>
        /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
        /// <param name="dayOfMonth">The recurrent day of month.</param>
        /// <param name="months">The recurrent months.</param>
        /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
        /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
        /// -or- <paramref name="months"/> is not specified
        /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="dayOfMonth"/> is not between 1 and the greatest days of the specified <paramref name="months"/>
        /// -or- one of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
        public MonthlyRecurrence(RecurrenceBehavior behavior, int dayOfMonth, RecurrentMonths months, IEnumerable <TimeSpan> timesOfDay)
            : base(behavior, timesOfDay)
        {
            if (months == default(RecurrentMonths))
            {
                throw new ArgumentException("Non specified argument.", "months");
            }

            //determine upper bound of a leap year
            var upperBound = (from value in FlagsEnum.FlagValues <RecurrentMonths>(months)
                              select DateTime.DaysInMonth(2012, FlagsEnum.PowerOfTwoExponent(value) + 1)).Max();

            if (dayOfMonth < 1 || dayOfMonth > upperBound)
            {
                throw new ArgumentOutOfRangeException("dayOfMonth"
                                                      , string.Format("Argument is not between 1 and the greatest days {0} of the specified months: {1}."
                                                                      , upperBound
                                                                      , months));
            }

            DayOfMonth = dayOfMonth;
            Months     = months;
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeeklyRecurrence"/> class
 /// executed every <paramref name="weeks"/>(s)
 /// on the specified <paramref name="weekDays"/>
 /// at the specified <paramref name="timesOfDay"/>.
 /// </summary>
 /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
 /// <param name="weekDays">The recurrent week days (ex: every <see cref="RecurrentWeekDays.WeekEnd"/>).</param>
 /// <param name="weeks">The recurrent week(s) (ex: every 2 weeks).</param>
 /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
 /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
 /// -or- <paramref name="weekDays"/> is not specified
 /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="weeks"/> is not strictly positive
 /// -or- one of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
 public WeeklyRecurrence(RecurrenceBehavior behavior, RecurrentWeekDays weekDays, int weeks, params TimeSpan[] timesOfDay)
     : this(behavior, weekDays, weeks, timesOfDay != null ? timesOfDay.AsEnumerable() : null)
 {
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DailyRecurrence"/> class
 /// executed every <paramref name="days"/>(s)
 /// at the specified <paramref name="timesOfDay"/>.
 /// </summary>
 /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
 /// <param name="days">The recurrent day(s) (ex: every two days).</param>
 /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
 /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
 /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="days"/> is not strictly positive
 /// -or- one of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
 public DailyRecurrence(RecurrenceBehavior behavior, int days, params TimeSpan[] timesOfDay)
     : this(behavior, days, timesOfDay != null ? timesOfDay.AsEnumerable() : null)
 {
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MonthlyRecurrence"/> class
 /// executed every <paramref name="weekDayOfMonth"/> of the specified <paramref name="months"/>
 /// at the specified <paramref name="timesOfDay"/>.
 /// </summary>
 /// <param name="behavior">The behavior regarding invalid times and ambiguous times.</param>
 /// <param name="weekDayOfMonth">The recurrent week day of month.</param>
 /// <param name="months">The recurrent months.</param>
 /// <param name="timesOfDay">The times of day the recurrence is executed.</param>
 /// <exception cref="ArgumentException"><paramref name="behavior"/> is not specified
 /// -or- <paramref name="weekDayOfMonth"/> is not specified
 /// -or- <paramref name="months"/> is not specified
 /// -or- <paramref name="timesOfDay"/> is null or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException">One of the specified <paramref name="timesOfDay"/> is lower than 00:00:00 or greater than or equal to 1.00:00:00.</exception>
 public MonthlyRecurrence(RecurrenceBehavior behavior, RecurrentWeekDaysOfMonth weekDayOfMonth, RecurrentMonths months, params TimeSpan[] timesOfDay)
     : this(behavior, weekDayOfMonth, months, timesOfDay != null ? timesOfDay.AsEnumerable() : null)
 {
 }