private RecurrencePattern CreateMonthlyRecurrence(Recurrence icalRecurrence, ExDateTime start, CalendarType calendarType) { RecurrencePattern result = null; if (icalRecurrence.ByDayList == null && icalRecurrence.BySetPosition == null) { int dayOfMonth = (icalRecurrence.ByMonthDay != null) ? icalRecurrence.ByMonthDay[0] : start.Day; result = new MonthlyRecurrencePattern(dayOfMonth, icalRecurrence.Interval, calendarType); } else if (icalRecurrence.ByDayList != null && icalRecurrence.ByMonthDay == null) { DaysOfWeek daysOfWeek = VItemBase.DaysOfWeekFromByDayList(icalRecurrence.ByDayList, start); int occurrenceNumber = icalRecurrence.ByDayList[0].OccurrenceNumber; RecurrenceOrderType?recurrenceOrderType = null; if (icalRecurrence.BySetPosition != null) { if (occurrenceNumber == 0 && icalRecurrence.BySetPosition[0] >= -1 && icalRecurrence.BySetPosition[0] <= 4 && icalRecurrence.BySetPosition[0] != 0) { recurrenceOrderType = new RecurrenceOrderType?((RecurrenceOrderType)icalRecurrence.BySetPosition[0]); } } else if (occurrenceNumber != 0) { recurrenceOrderType = new RecurrenceOrderType?((RecurrenceOrderType)occurrenceNumber); } if (recurrenceOrderType != null) { result = new MonthlyThRecurrencePattern(daysOfWeek, recurrenceOrderType.Value, icalRecurrence.Interval, calendarType); } } return(result); }
private RecurrencePattern CreateWeeklyRecurrence(Recurrence icalRecurrence, ExDateTime start) { RecurrencePattern result; if (icalRecurrence.ByDayList != null) { DaysOfWeek daysOfWeek = VItemBase.DaysOfWeekFromByDayList(icalRecurrence.ByDayList, start); result = new WeeklyRecurrencePattern(daysOfWeek, icalRecurrence.Interval, icalRecurrence.WorkWeekStart); } else { result = new WeeklyRecurrencePattern((DaysOfWeek)(1 << (int)start.DayOfWeek), icalRecurrence.Interval, icalRecurrence.WorkWeekStart); } return(result); }