public override bool Equals(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth) { if (!(value is WeeklyRecurrencePattern)) { return(false); } WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)value; return(weeklyRecurrencePattern.DaysOfWeek == this.daysOfWeek && weeklyRecurrencePattern.FirstDayOfWeek == this.FirstDayOfWeek && base.Equals(value, ignoreCalendarTypeAndIsLeapMonth)); }
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); }
private void SetPatternSpecificProperties(RecurrencePattern pattern) { if (pattern is DailyRecurrencePattern) { DailyRecurrencePattern dailyRecurrencePattern = (DailyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Daily; this.Type = RecurrenceTypeInBlob.Minute; this.Period = dailyRecurrencePattern.RecurrenceInterval * 24 * 60; return; } if (pattern is WeeklyRecurrencePattern) { WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Weekly; this.Type = RecurrenceTypeInBlob.Week; this.Period = weeklyRecurrencePattern.RecurrenceInterval; this.DayMask = weeklyRecurrencePattern.DaysOfWeek; this.FirstDayOfWeek = (int)((WeeklyRecurrencePattern)pattern).FirstDayOfWeek; return; } if (pattern is MonthlyRecurrencePattern) { MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Monthly; this.Type = ((monthlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month); this.Period = monthlyRecurrencePattern.RecurrenceInterval; this.DayOfMonth = monthlyRecurrencePattern.DayOfMonth; return; } if (pattern is YearlyRecurrencePattern) { YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Yearly; this.Type = ((yearlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month); this.DayOfMonth = yearlyRecurrencePattern.DayOfMonth; this.Period = 12; return; } if (pattern is MonthlyThRecurrencePattern) { MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern; this.Group = RecurrenceGroup.Monthly; this.Type = ((monthlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth); this.DayMask = monthlyThRecurrencePattern.DaysOfWeek; this.NthOccurrence = monthlyThRecurrencePattern.Order; this.Period = monthlyThRecurrencePattern.RecurrenceInterval; return; } if (pattern is YearlyThRecurrencePattern) { YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern; this.Group = RecurrenceGroup.Yearly; this.Type = ((yearlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth); this.DayMask = yearlyThRecurrencePattern.DaysOfWeek; this.NthOccurrence = yearlyThRecurrencePattern.Order; this.MonthOfYear = yearlyThRecurrencePattern.Month; this.Period = 12; return; } if (pattern is DailyRegeneratingPattern) { DailyRegeneratingPattern dailyRegeneratingPattern = (DailyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Minute; this.Group = RecurrenceGroup.Daily; this.Period = dailyRegeneratingPattern.RecurrenceInterval * 24 * 60; return; } if (pattern is WeeklyRegeneratingPattern) { WeeklyRegeneratingPattern weeklyRegeneratingPattern = (WeeklyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Minute; this.Group = RecurrenceGroup.Weekly; this.DayMask = DaysOfWeek.Monday; this.Period = weeklyRegeneratingPattern.RecurrenceInterval * 7 * 24 * 60; return; } if (pattern is MonthlyRegeneratingPattern) { MonthlyRegeneratingPattern monthlyRegeneratingPattern = (MonthlyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.MonthNth; this.Group = RecurrenceGroup.Monthly; this.DayMask = DaysOfWeek.Monday; this.NthOccurrence = (RecurrenceOrderType)0; this.Period = monthlyRegeneratingPattern.RecurrenceInterval; return; } if (pattern is YearlyRegeneratingPattern) { YearlyRegeneratingPattern yearlyRegeneratingPattern = (YearlyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Month; this.Group = RecurrenceGroup.Yearly; this.DayOfMonth = 1; this.Period = 12 * yearlyRegeneratingPattern.RecurrenceInterval; } }
protected Recurrence ICalRecurrenceFromXsoRecurrence(Recurrence xsoRecurrence) { Recurrence recurrence = new Recurrence(); RecurrencePattern pattern = xsoRecurrence.Pattern; RecurrenceRange range = xsoRecurrence.Range; if (pattern is DailyRecurrencePattern) { recurrence.Frequency = Frequency.Daily; } else if (pattern is WeeklyRecurrencePattern) { recurrence.Frequency = Frequency.Weekly; WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(weeklyRecurrencePattern.DaysOfWeek); recurrence.WorkWeekStart = weeklyRecurrencePattern.FirstDayOfWeek; } else if (pattern is MonthlyRecurrencePattern) { recurrence.Frequency = Frequency.Monthly; MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern; recurrence.ByMonthDay = new int[] { monthlyRecurrencePattern.DayOfMonth }; } else if (pattern is MonthlyThRecurrencePattern) { recurrence.Frequency = Frequency.Monthly; MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(monthlyThRecurrencePattern.DaysOfWeek); int order = (int)monthlyThRecurrencePattern.Order; if (recurrence.ByDayList.Length == 1) { recurrence.ByDayList[0].OccurrenceNumber = order; } else { recurrence.BySetPosition = new int[] { order }; } } else if (pattern is YearlyRecurrencePattern) { recurrence.Frequency = Frequency.Yearly; YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern; recurrence.ByMonth = new int[] { yearlyRecurrencePattern.Month }; recurrence.ByMonthDay = new int[] { yearlyRecurrencePattern.DayOfMonth }; } else if (pattern is YearlyThRecurrencePattern) { recurrence.Frequency = Frequency.Yearly; YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern; recurrence.ByMonth = new int[] { yearlyThRecurrencePattern.Month }; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(yearlyThRecurrencePattern.DaysOfWeek); int order2 = (int)yearlyThRecurrencePattern.Order; if (recurrence.ByDayList.Length == 1) { recurrence.ByDayList[0].OccurrenceNumber = order2; } else { recurrence.BySetPosition = new int[] { order2 }; } } IntervalRecurrencePattern intervalRecurrencePattern = pattern as IntervalRecurrencePattern; if (intervalRecurrencePattern != null) { recurrence.Interval = intervalRecurrencePattern.RecurrenceInterval; } else { recurrence.Interval = 1; } if (range is EndDateRecurrenceRange) { EndDateRecurrenceRange endDateRecurrenceRange = (EndDateRecurrenceRange)range; recurrence.UntilDateTime = (DateTime)(endDateRecurrenceRange.EndDate + xsoRecurrence.StartOffset).ToUtc(); } else if (range is NumberedRecurrenceRange) { NumberedRecurrenceRange numberedRecurrenceRange = (NumberedRecurrenceRange)range; recurrence.Count = numberedRecurrenceRange.NumberOfOccurrences; } return(recurrence); }