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)); }
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(); }
public static HolidaySchedule ParseADString(string schedule) { return(HolidaySchedule.HolidayFromString(schedule, true)); }
public static HolidaySchedule Parse(string schedule) { return(HolidaySchedule.HolidayFromString(schedule, false)); }
public override bool Equals(object obj) { HolidaySchedule holidaySchedule = obj as HolidaySchedule; return(holidaySchedule != null && string.Equals(this.ToADString(), holidaySchedule.ToADString(), StringComparison.OrdinalIgnoreCase)); }
public void Validate() { HolidaySchedule.ValidateName(this.name); HolidaySchedule.ValidateGreeting(this.introductoryGreeting); HolidaySchedule.ValidateSchedule(this.scheduleDate, this.endDate); }