コード例 #1
0
        internal Appointment(
            Doctor doctor,
            Client client,
            AppointmentDate appointmentDate,
            OfficeRoom officeRoom)
        {
            Guard.AgainstNullObject <InvalidDoctorException>(doctor, nameof(doctor));
            Guard.AgainstNullObject <InvalidClientException>(client, nameof(client));
            Guard.AgainstNullObject <InvalidAppointmentDateException>(appointmentDate, nameof(appointmentDate));
            Guard.AgainstNullObject <InvalidOfficeRoomException>(officeRoom, nameof(officeRoom));

            if (officeRoom.OfficeRoomType == OfficeRoomType.SurgeryRoom && doctor.DoctorType.Value != 2)
            {
                throw new InvalidDoctorException("Doctor: surgery room requires specialist");
            }

            this.Doctor          = doctor;
            this.Client          = client;
            this.AppointmentDate = appointmentDate;
            this.OfficeRoom      = officeRoom;
        }