// Token: 0x06001218 RID: 4632 RVA: 0x0006247C File Offset: 0x0006067C private static RecurrenceRange CreateRecurrenceRange(ExDateTime startDate, RecurrenceData recurrenceData) { RecurrenceRange recurrenceRange = null; try { if (recurrenceData.HasOccurences()) { recurrenceRange = new NumberedRecurrenceRange(); ((NumberedRecurrenceRange)recurrenceRange).NumberOfOccurrences = (int)recurrenceData.Occurrences; } else if (recurrenceData.HasUntil()) { recurrenceRange = new EndDateRecurrenceRange(); ((EndDateRecurrenceRange)recurrenceRange).EndDate = recurrenceData.Until; } else { recurrenceRange = new NoEndRecurrenceRange(); } recurrenceRange.StartDate = startDate; } catch (ArgumentException ex) { throw new ConversionException(ex.Message); } return(recurrenceRange); }
protected override void InternalCopyFromModified(IProperty srcProperty) { CalendarItem calendarItem = null; Task task = null; if (this.recurrenceType == TypeOfRecurrence.Calendar) { calendarItem = (base.XsoItem as CalendarItem); if (calendarItem == null) { throw new UnexpectedTypeException("CalendarItem", base.XsoItem); } if (!calendarItem.IsOrganizer()) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "InternalCopyFromModified::Skip Recurrence change in case of attendee."); return; } } else if (this.recurrenceType == TypeOfRecurrence.Task) { task = (base.XsoItem as Task); if (task == null) { throw new UnexpectedTypeException("Task", base.XsoItem); } } INestedProperty nestedProperty = srcProperty as INestedProperty; if (nestedProperty == null) { throw new UnexpectedTypeException("INestedProperty", srcProperty); } RecurrenceData recurrenceData = nestedProperty.NestedData as RecurrenceData; if (recurrenceData == null) { throw new UnexpectedTypeException("RecurrenceData", nestedProperty.NestedData); } Recurrence recurrence = (this.recurrenceType == TypeOfRecurrence.Calendar) ? calendarItem.Recurrence : task.Recurrence; RecurrencePattern recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); ExDateTime startDate = ExDateTime.MinValue; ExDateTime endDate = ExDateTime.MinValue; if (this.recurrenceType == TypeOfRecurrence.Calendar) { ExDateTime startTime = calendarItem.StartTime; ExTimeZone exTimeZoneFromItem = TimeZoneHelper.GetExTimeZoneFromItem(calendarItem); startDate = exTimeZoneFromItem.ConvertDateTime(startTime); if (recurrenceData.HasUntil()) { ExDateTime until = recurrenceData.Until; endDate = exTimeZoneFromItem.ConvertDateTime(until); } } else if (this.recurrenceType == TypeOfRecurrence.Task) { startDate = recurrenceData.Start; if (recurrenceData.HasUntil()) { endDate = recurrenceData.Until; } } RecurrenceRange range; try { if (recurrenceData.HasOccurences()) { range = new NumberedRecurrenceRange(startDate, (int)recurrenceData.Occurrences); } else if (recurrenceData.HasUntil()) { range = new EndDateRecurrenceRange(startDate, endDate); } else { range = new NoEndRecurrenceRange(startDate); } } catch (ArgumentException ex) { throw new ConversionException(ex.Message); } bool ignoreCalendarTypeAndIsLeapMonth = recurrenceData.ProtocolVersion < 140; if (recurrence != null && recurrence.Pattern != null && recurrence.Pattern.Equals(recurrencePattern, ignoreCalendarTypeAndIsLeapMonth)) { recurrencePattern = recurrence.Pattern; } try { if (this.recurrenceType == TypeOfRecurrence.Calendar) { ExTimeZone exTimeZoneFromItem2 = TimeZoneHelper.GetExTimeZoneFromItem(calendarItem); try { calendarItem.Recurrence = new Recurrence(recurrencePattern, range, exTimeZoneFromItem2, null); goto IL_295; } catch (ArgumentOutOfRangeException) { if (recurrenceData.CalendarType == CalendarType.Default) { recurrenceData.CalendarType = CalendarType.Gregorian; AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "Replace calendar recurrence calendar type with Gregorian."); recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); calendarItem.Recurrence = new Recurrence(recurrencePattern, range, exTimeZoneFromItem2, null); goto IL_295; } throw; } } try { task.Recurrence = new Recurrence(recurrencePattern, range); } catch (ArgumentOutOfRangeException) { if (recurrenceData.CalendarType != CalendarType.Default) { throw; } recurrenceData.CalendarType = CalendarType.Gregorian; AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "Replace task recurrence calendar type with Gregorian."); recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); task.Recurrence = new Recurrence(recurrencePattern, range); } task[TaskSchema.IsOneOff] = recurrenceData.DeadOccur; IL_295 :; } catch (NotSupportedException ex2) { throw new ConversionException(ex2.Message); } }