private bool IsValidRecurrencePattern(RecurrencePattern pattern) { if (!RecurrencePattern.IsValidPattern(pattern)) { return(false); } if (this.Duration <= TimeSpan.Zero) { return(false); } if (this.RecurrenceRangeType == RecurrenceRangeType.RepeatUntil && this.RecursUntil < this.Start) { return(false); } if (!this.IsValidDuration(pattern)) { return(false); } switch (this.RecurrenceType) { case RecurrenceType.Monthly: return(this.DayOfMonth > 0 && this.DayOfMonth < 32); case RecurrenceType.Yearly: int daysInMoth = DateTime.DaysInMonth(this.Start.Year, this.MonthOfYear); return(this.DayOfMonth <= daysInMoth && this.DayOfMonth > 0); } return(true); }