示例#1
0
        private static HolidaySchedule HolidayFromString(string schedule, bool fromAD)
        {
            if (schedule == null || schedule.Length == 0)
            {
                throw new FormatException(DataStrings.InvalidHolidayScheduleFormat);
            }
            string[] array = schedule.Split(new char[]
            {
                ','
            });
            if (array == null || array.Length < 3 || array.Length > 4)
            {
                throw new FormatException(DataStrings.InvalidHolidayScheduleFormat);
            }
            DateTime dateTime = DateTime.MinValue;

            dateTime = HolidaySchedule.StringToDate(array[2], fromAD);
            DateTime end = dateTime;

            if (array.Length > 3)
            {
                end = HolidaySchedule.StringToDate(array[3], fromAD);
            }
            return(new HolidaySchedule(array[0], array[1], dateTime, end));
        }
示例#2
0
        public HolidaySchedule(PSObject importedObject)
        {
            this.name = (string)importedObject.Properties["Name"].Value;
            this.introductoryGreeting = (string)importedObject.Properties["Greeting"].Value;
            string datestring = (string)importedObject.Properties["StartDate"].Value;

            this.scheduleDate = HolidaySchedule.StringToDate(datestring, false);
            datestring        = (string)importedObject.Properties["EndDate"].Value;
            this.endDate      = HolidaySchedule.StringToDate(datestring, false);
            this.Validate();
        }
示例#3
0
 public static HolidaySchedule ParseADString(string schedule)
 {
     return(HolidaySchedule.HolidayFromString(schedule, true));
 }
示例#4
0
 public static HolidaySchedule Parse(string schedule)
 {
     return(HolidaySchedule.HolidayFromString(schedule, false));
 }
示例#5
0
        public override bool Equals(object obj)
        {
            HolidaySchedule holidaySchedule = obj as HolidaySchedule;

            return(holidaySchedule != null && string.Equals(this.ToADString(), holidaySchedule.ToADString(), StringComparison.OrdinalIgnoreCase));
        }
示例#6
0
 public void Validate()
 {
     HolidaySchedule.ValidateName(this.name);
     HolidaySchedule.ValidateGreeting(this.introductoryGreeting);
     HolidaySchedule.ValidateSchedule(this.scheduleDate, this.endDate);
 }