Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the WeekRange class. Constructor creates WeekRange object by selected values
        /// </summary>
        /// <param name="dayOfWeek">DayOfWeek when period starts</param>
        /// <param name="startTime">Start time</param>
        /// <param name="endTime">End time</param>
        public WeekRange(DayOfWeek dayOfWeek, TimeSpan startTime, TimeSpan endTime)
        {
            if (startTime.Days > 0 || endTime.Days > 0)
            {
                throw new Exception("To WeekRange constructor was passed TimeSpan parameters where days is greater then 0");
            }

            Start = new WeekTime(dayOfWeek, startTime);
            End = new WeekTime(startTime >= endTime ? dayOfWeek.NextDayOfWeek() : dayOfWeek, endTime);
        }