Example #1
0
 private WorkingWeek(WorkingDay monday,
                     WorkingDay tuesday,
                     WorkingDay wednesday,
                     WorkingDay thursday,
                     WorkingDay friday,
                     WorkingDay saturday,
                     WorkingDay sunday)
 {
     _monday    = monday;
     _tuesday   = tuesday;
     _wednesday = wednesday;
     _thursday  = thursday;
     _friday    = friday;
     _saturday  = saturday;
     _sunday    = sunday;
 }
Example #2
0
        public WorkingWeek WithDay(WorkingDay day)
        {
            if (day == null)
            {
                throw new ArgumentNullException(nameof(day));
            }

            var monday    = day.DayOfWeek == DayOfWeek.Monday ? day : this[DayOfWeek.Monday];
            var tuesday   = day.DayOfWeek == DayOfWeek.Tuesday ? day : this[DayOfWeek.Tuesday];
            var wednesday = day.DayOfWeek == DayOfWeek.Wednesday ? day : this[DayOfWeek.Wednesday];
            var thursday  = day.DayOfWeek == DayOfWeek.Thursday ? day : this[DayOfWeek.Thursday];
            var friday    = day.DayOfWeek == DayOfWeek.Friday ? day : this[DayOfWeek.Friday];
            var saturday  = day.DayOfWeek == DayOfWeek.Saturday ? day : this[DayOfWeek.Saturday];
            var sunday    = day.DayOfWeek == DayOfWeek.Sunday ? day : this[DayOfWeek.Sunday];

            return(new WorkingWeek(monday, tuesday, wednesday, thursday, friday, saturday, sunday));
        }
Example #3
0
        public static WorkingWeek Create(WorkingDay monday,
                                         WorkingDay tuesday,
                                         WorkingDay wednesday,
                                         WorkingDay thursday,
                                         WorkingDay friday,
                                         WorkingDay saturday,
                                         WorkingDay sunday)
        {
            if (monday == null)
            {
                throw new ArgumentNullException(nameof(monday));
            }

            if (tuesday == null)
            {
                throw new ArgumentNullException(nameof(tuesday));
            }

            if (wednesday == null)
            {
                throw new ArgumentNullException(nameof(wednesday));
            }

            if (thursday == null)
            {
                throw new ArgumentNullException(nameof(thursday));
            }

            if (friday == null)
            {
                throw new ArgumentNullException(nameof(friday));
            }

            if (saturday == null)
            {
                throw new ArgumentNullException(nameof(saturday));
            }

            if (sunday == null)
            {
                throw new ArgumentNullException(nameof(sunday));
            }

            if (monday.DayOfWeek != DayOfWeek.Monday)
            {
                throw new ArgumentOutOfRangeException(nameof(monday));
            }

            if (tuesday.DayOfWeek != DayOfWeek.Tuesday)
            {
                throw new ArgumentOutOfRangeException(nameof(tuesday));
            }

            if (wednesday.DayOfWeek != DayOfWeek.Wednesday)
            {
                throw new ArgumentOutOfRangeException(nameof(wednesday));
            }

            if (thursday.DayOfWeek != DayOfWeek.Thursday)
            {
                throw new ArgumentOutOfRangeException(nameof(thursday));
            }

            if (friday.DayOfWeek != DayOfWeek.Friday)
            {
                throw new ArgumentOutOfRangeException(nameof(friday));
            }

            if (saturday.DayOfWeek != DayOfWeek.Saturday)
            {
                throw new ArgumentOutOfRangeException(nameof(saturday));
            }

            if (sunday.DayOfWeek != DayOfWeek.Sunday)
            {
                throw new ArgumentOutOfRangeException(nameof(sunday));
            }

            return(new WorkingWeek(monday,
                                   tuesday,
                                   wednesday,
                                   thursday,
                                   friday,
                                   saturday,
                                   sunday));
        }