public Appointment Parse(IList <string> stringValue, DateTime start, DateTime end) { iCalendarEntryParser parser = new iCalendarEntryParser(); iCalendarEntryContainer entryContainer = parser.ParseString(String.Join("\n", stringValue.ToArray())); this.rule = entryContainer.GetPropertyValue <VRecurrenceRule>(RecurrenceRuleProperty.TokenName); if (this.rule == null) { return(null); } Appointment pattern = Storage.CreateAppointment(AppointmentType.Pattern); pattern.Start = start; pattern.End = end; iCalendarHelper.ApplyRecurrenceInfo(pattern.RecurrenceInfo, start, rule); ExceptionDateTimesProperty exceptionProperty = entryContainer.GetProperty(ExceptionDateTimesProperty.TokenName) as ExceptionDateTimesProperty; if (exceptionProperty != null) { exceptionProperty.ApplyTimeZone(); OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo); foreach (var item in exceptionProperty.Values) { int indx = calculator.FindOccurrenceIndex(item, pattern); if (indx < 0) { continue; } pattern.CreateException(AppointmentType.DeletedOccurrence, indx); } } return(pattern); }
int CalculateOccurrenceIndex(Appointment pattern, EventDateTime originalStartTime) { OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo); return(calculator.FindOccurrenceIndex(ConvertDateTime(originalStartTime), pattern)); }