public static bool IsRecurrencePatternEqual(RecurrencePattern p1, RecurrencePattern p2) { if (p1 == null != (p2 == null)) { return(false); } if (p1 != null) { if (!p1.GetType().Equals(p2.GetType())) { return(false); } DailyRecurrencePattern dailyRecurrencePattern = p1 as DailyRecurrencePattern; if (dailyRecurrencePattern != null) { DailyRecurrencePattern dailyRecurrencePattern2 = p2 as DailyRecurrencePattern; return(dailyRecurrencePattern.RecurrenceInterval == dailyRecurrencePattern2.RecurrenceInterval); } WeeklyRecurrencePattern weeklyRecurrencePattern = p1 as WeeklyRecurrencePattern; if (weeklyRecurrencePattern != null) { WeeklyRecurrencePattern weeklyRecurrencePattern2 = p2 as WeeklyRecurrencePattern; return(weeklyRecurrencePattern.DaysOfWeek == weeklyRecurrencePattern2.DaysOfWeek && weeklyRecurrencePattern.FirstDayOfWeek == weeklyRecurrencePattern2.FirstDayOfWeek && weeklyRecurrencePattern.RecurrenceInterval == weeklyRecurrencePattern2.RecurrenceInterval); } MonthlyRecurrencePattern monthlyRecurrencePattern = p1 as MonthlyRecurrencePattern; if (monthlyRecurrencePattern != null) { MonthlyRecurrencePattern monthlyRecurrencePattern2 = p2 as MonthlyRecurrencePattern; return(monthlyRecurrencePattern.CalendarType == monthlyRecurrencePattern2.CalendarType && monthlyRecurrencePattern.DayOfMonth == monthlyRecurrencePattern2.DayOfMonth && monthlyRecurrencePattern.RecurrenceInterval == monthlyRecurrencePattern2.RecurrenceInterval); } MonthlyThRecurrencePattern monthlyThRecurrencePattern = p1 as MonthlyThRecurrencePattern; if (monthlyThRecurrencePattern != null) { MonthlyThRecurrencePattern monthlyThRecurrencePattern2 = p2 as MonthlyThRecurrencePattern; return(monthlyThRecurrencePattern.CalendarType == monthlyThRecurrencePattern2.CalendarType && monthlyThRecurrencePattern.DaysOfWeek == monthlyThRecurrencePattern2.DaysOfWeek && monthlyThRecurrencePattern.Order == monthlyThRecurrencePattern2.Order && monthlyThRecurrencePattern.RecurrenceInterval == monthlyThRecurrencePattern2.RecurrenceInterval); } YearlyRecurrencePattern yearlyRecurrencePattern = p1 as YearlyRecurrencePattern; if (yearlyRecurrencePattern != null) { YearlyRecurrencePattern yearlyRecurrencePattern2 = p2 as YearlyRecurrencePattern; return(yearlyRecurrencePattern.CalendarType == yearlyRecurrencePattern2.CalendarType && yearlyRecurrencePattern.DayOfMonth == yearlyRecurrencePattern2.DayOfMonth && yearlyRecurrencePattern.IsLeapMonth == yearlyRecurrencePattern2.IsLeapMonth && yearlyRecurrencePattern.Month == yearlyRecurrencePattern2.Month); } YearlyThRecurrencePattern yearlyThRecurrencePattern = p1 as YearlyThRecurrencePattern; if (yearlyThRecurrencePattern != null) { YearlyThRecurrencePattern yearlyThRecurrencePattern2 = p2 as YearlyThRecurrencePattern; return(yearlyThRecurrencePattern.CalendarType == yearlyThRecurrencePattern2.CalendarType && yearlyThRecurrencePattern.DaysOfWeek == yearlyThRecurrencePattern2.DaysOfWeek && yearlyThRecurrencePattern.IsLeapMonth == yearlyThRecurrencePattern2.IsLeapMonth && yearlyThRecurrencePattern.Month == yearlyThRecurrencePattern2.Month && yearlyThRecurrencePattern.Order == yearlyThRecurrencePattern2.Order); } } return(true); }
public RecurrencePattern ConvertStorageToEntities(YearlyThRecurrencePattern value) { if (value != null) { return(new RelativeYearlyRecurrencePattern { DaysOfWeek = this.dayOfWeekConverter.Convert(value.DaysOfWeek), Index = this.weekIndexConverter.Convert(value.Order), Interval = value.RecurrenceInterval, Month = value.Month }); } return(null); }
public RecurrencePattern Convert(RecurrencePattern value) { if (value == null) { return(null); } DailyRecurrencePattern dailyRecurrencePattern = value as DailyRecurrencePattern; if (dailyRecurrencePattern != null) { return(PatternConverter.dailyPatternConverter.ConvertStorageToEntities(dailyRecurrencePattern)); } WeeklyRecurrencePattern weeklyRecurrencePattern = value as WeeklyRecurrencePattern; if (weeklyRecurrencePattern != null) { return(PatternConverter.weeklyPatternConverter.ConvertStorageToEntities(weeklyRecurrencePattern)); } MonthlyRecurrencePattern monthlyRecurrencePattern = value as MonthlyRecurrencePattern; if (monthlyRecurrencePattern != null) { return(PatternConverter.monthlyPatternConverter.ConvertStorageToEntities(monthlyRecurrencePattern)); } MonthlyThRecurrencePattern monthlyThRecurrencePattern = value as MonthlyThRecurrencePattern; if (monthlyThRecurrencePattern != null) { return(PatternConverter.monthlyPatternConverter.ConvertStorageToEntities(monthlyThRecurrencePattern)); } YearlyRecurrencePattern yearlyRecurrencePattern = value as YearlyRecurrencePattern; if (yearlyRecurrencePattern != null) { return(PatternConverter.yearlyPatternConverter.ConvertStorageToEntities(yearlyRecurrencePattern)); } YearlyThRecurrencePattern yearlyThRecurrencePattern = value as YearlyThRecurrencePattern; if (yearlyThRecurrencePattern != null) { return(PatternConverter.yearlyPatternConverter.ConvertStorageToEntities(yearlyThRecurrencePattern)); } if (value is DailyRegeneratingPattern || value is WeeklyRegeneratingPattern || value is MonthlyRegeneratingPattern || value is YearlyRegeneratingPattern) { throw new NotImplementedException("Regenerating tasks are not implemented in Entities yet."); } throw new ArgumentValueCannotBeParsedException("value", value.GetType().FullName, typeof(RecurrencePattern).FullName); }
public static RecurrencePattern CloneRecurrencePattern(RecurrencePattern pattern) { RecurrencePattern result = null; if (pattern == null) { return(result); } DailyRecurrencePattern dailyRecurrencePattern = pattern as DailyRecurrencePattern; if (dailyRecurrencePattern != null) { return(new DailyRecurrencePattern(dailyRecurrencePattern.RecurrenceInterval)); } MonthlyRecurrencePattern monthlyRecurrencePattern = pattern as MonthlyRecurrencePattern; if (monthlyRecurrencePattern != null) { return(new MonthlyRecurrencePattern(monthlyRecurrencePattern.DayOfMonth, monthlyRecurrencePattern.RecurrenceInterval, monthlyRecurrencePattern.CalendarType)); } MonthlyThRecurrencePattern monthlyThRecurrencePattern = pattern as MonthlyThRecurrencePattern; if (monthlyThRecurrencePattern != null) { return(new MonthlyThRecurrencePattern(monthlyThRecurrencePattern.DaysOfWeek, monthlyThRecurrencePattern.Order, monthlyThRecurrencePattern.RecurrenceInterval, monthlyThRecurrencePattern.CalendarType)); } WeeklyRecurrencePattern weeklyRecurrencePattern = pattern as WeeklyRecurrencePattern; if (weeklyRecurrencePattern != null) { return(new WeeklyRecurrencePattern(weeklyRecurrencePattern.DaysOfWeek, weeklyRecurrencePattern.RecurrenceInterval, weeklyRecurrencePattern.FirstDayOfWeek)); } YearlyRecurrencePattern yearlyRecurrencePattern = pattern as YearlyRecurrencePattern; if (yearlyRecurrencePattern != null) { return(new YearlyRecurrencePattern(yearlyRecurrencePattern.DayOfMonth, yearlyRecurrencePattern.Month, yearlyRecurrencePattern.IsLeapMonth, yearlyRecurrencePattern.CalendarType)); } YearlyThRecurrencePattern yearlyThRecurrencePattern = pattern as YearlyThRecurrencePattern; if (yearlyThRecurrencePattern != null) { return(new YearlyThRecurrencePattern(yearlyThRecurrencePattern.DaysOfWeek, yearlyThRecurrencePattern.Order, yearlyThRecurrencePattern.Month, yearlyThRecurrencePattern.IsLeapMonth, yearlyThRecurrencePattern.CalendarType)); } throw new ArgumentException("Unhandled RecurrencePattern type."); }
protected Recurrence CreateRecurrenceFromRequest() { Recurrence result = null; if (base.IsParameterSet("RcrT")) { OwaRecurrenceType owaRecurrenceType = (OwaRecurrenceType)base.GetParameter("RcrT"); RecurrencePattern recurrencePattern = null; OwaRecurrenceType owaRecurrenceType2 = owaRecurrenceType; if (owaRecurrenceType2 <= (OwaRecurrenceType.Monthly | OwaRecurrenceType.MonthlyTh)) { if (owaRecurrenceType2 <= OwaRecurrenceType.Monthly) { switch (owaRecurrenceType2) { case OwaRecurrenceType.Daily: recurrencePattern = new DailyRecurrencePattern((int)base.GetParameter("RcrI")); break; case OwaRecurrenceType.None | OwaRecurrenceType.Daily: break; case OwaRecurrenceType.Weekly: recurrencePattern = new WeeklyRecurrencePattern((DaysOfWeek)base.GetParameter("RcrDys"), (int)base.GetParameter("RcrI")); break; default: if (owaRecurrenceType2 == OwaRecurrenceType.Monthly) { recurrencePattern = new MonthlyRecurrencePattern((int)base.GetParameter("RcrDy"), (int)base.GetParameter("RcrI")); } break; } } else if (owaRecurrenceType2 != OwaRecurrenceType.Yearly) { if (owaRecurrenceType2 != (OwaRecurrenceType.Daily | OwaRecurrenceType.DailyEveryWeekday)) { if (owaRecurrenceType2 == (OwaRecurrenceType.Monthly | OwaRecurrenceType.MonthlyTh)) { recurrencePattern = new MonthlyThRecurrencePattern((DaysOfWeek)base.GetParameter("RcrDys"), (RecurrenceOrderType)base.GetParameter("RcrO"), (int)base.GetParameter("RcrI")); } } else { recurrencePattern = new WeeklyRecurrencePattern(DaysOfWeek.Weekdays); } } else { recurrencePattern = new YearlyRecurrencePattern((int)base.GetParameter("RcrDy"), (int)base.GetParameter("RcrM")); } } else if (owaRecurrenceType2 <= (OwaRecurrenceType.Daily | OwaRecurrenceType.DailyRegenerating)) { if (owaRecurrenceType2 != (OwaRecurrenceType.Yearly | OwaRecurrenceType.YearlyTh)) { if (owaRecurrenceType2 == (OwaRecurrenceType.Daily | OwaRecurrenceType.DailyRegenerating)) { recurrencePattern = new DailyRegeneratingPattern((int)base.GetParameter("RgrI")); } } else { recurrencePattern = new YearlyThRecurrencePattern((DaysOfWeek)base.GetParameter("RcrDys"), (RecurrenceOrderType)base.GetParameter("RcrO"), (int)base.GetParameter("RcrM")); } } else if (owaRecurrenceType2 != (OwaRecurrenceType.Weekly | OwaRecurrenceType.WeeklyRegenerating)) { if (owaRecurrenceType2 != (OwaRecurrenceType.Monthly | OwaRecurrenceType.MonthlyRegenerating)) { if (owaRecurrenceType2 == (OwaRecurrenceType.Yearly | OwaRecurrenceType.YearlyRegenerating)) { recurrencePattern = new YearlyRegeneratingPattern((int)base.GetParameter("RgrI")); } } else { recurrencePattern = new MonthlyRegeneratingPattern((int)base.GetParameter("RgrI")); } } else { recurrencePattern = new WeeklyRegeneratingPattern((int)base.GetParameter("RgrI")); } if (owaRecurrenceType != OwaRecurrenceType.None) { RecurrenceRangeType recurrenceRangeType = (RecurrenceRangeType)base.GetParameter("RcrRngT"); ExDateTime startDate = (ExDateTime)base.GetParameter("RcrRngS"); RecurrenceRange recurrenceRange; switch (recurrenceRangeType) { case RecurrenceRangeType.Numbered: recurrenceRange = new NumberedRecurrenceRange(startDate, (int)base.GetParameter("RcrRngO")); goto IL_2C8; case RecurrenceRangeType.EndDate: recurrenceRange = new EndDateRecurrenceRange(startDate, (ExDateTime)base.GetParameter("RcrRngE")); goto IL_2C8; } recurrenceRange = new NoEndRecurrenceRange(startDate); IL_2C8: if (recurrencePattern != null && recurrenceRange != null) { result = new Recurrence(recurrencePattern, recurrenceRange); } } } return(result); }
// Token: 0x060001CB RID: 459 RVA: 0x00011324 File Offset: 0x0000F524 private static Recurrence CreateRecurrenceFromRequest(HttpRequest request, ExDateTime startDate, UserContext userContext) { OwaRecurrenceType newRecurrenceTypeFromPost = EditRecurrencePreFormAction.GetNewRecurrenceTypeFromPost(request); RecurrencePattern pattern = null; Recurrence result = null; DaysOfWeek defaultDaysOfWeek = CalendarUtilities.ConvertDateTimeToDaysOfWeek(startDate); int defaultValue = CalendarUtilities.ComputeDayOfMonthOrder(startDate); OwaRecurrenceType owaRecurrenceType = newRecurrenceTypeFromPost; if (owaRecurrenceType <= OwaRecurrenceType.Yearly) { switch (owaRecurrenceType) { case OwaRecurrenceType.Daily: { int num = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtinterval", 1); num = Math.Max(1, num); pattern = new DailyRecurrencePattern(num); break; } case OwaRecurrenceType.None | OwaRecurrenceType.Daily: break; case OwaRecurrenceType.Weekly: { int num = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtinterval", 1); num = Math.Max(1, num); pattern = new WeeklyRecurrencePattern(EditRecurrencePreFormAction.ParseDayCheckboxes(request, defaultDaysOfWeek), num); break; } default: if (owaRecurrenceType != OwaRecurrenceType.Monthly) { if (owaRecurrenceType == OwaRecurrenceType.Yearly) { int num2 = EditRecurrencePreFormAction.GetIntFormParameter(request, "selRcrYD", startDate.Day); int intFormParameter = EditRecurrencePreFormAction.GetIntFormParameter(request, "selRcrYM", startDate.Month); num2 = Math.Min(ExDateTime.DaysInMonth(startDate.Year, intFormParameter), num2); pattern = new YearlyRecurrencePattern(num2, intFormParameter); } } else { int num2 = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtRcrMD", startDate.Day); int num = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtRcrMM", 1); num = Math.Max(1, num); pattern = new MonthlyRecurrencePattern(num2, num); } break; } } else if (owaRecurrenceType != (OwaRecurrenceType.Daily | OwaRecurrenceType.DailyEveryWeekday)) { if (owaRecurrenceType != (OwaRecurrenceType.Monthly | OwaRecurrenceType.MonthlyTh)) { if (owaRecurrenceType == (OwaRecurrenceType.Yearly | OwaRecurrenceType.YearlyTh)) { int intFormParameter2 = EditRecurrencePreFormAction.GetIntFormParameter(request, "selRcrYTI", defaultValue); int intFormParameter = EditRecurrencePreFormAction.GetIntFormParameter(request, "selRcrYTM", startDate.Month); DaysOfWeek daysOfWeek = EditRecurrencePreFormAction.ParseDaysOfWeek(request, "selRcrThD", defaultDaysOfWeek); pattern = new YearlyThRecurrencePattern(daysOfWeek, (RecurrenceOrderType)intFormParameter2, intFormParameter); } } else { int intFormParameter2 = EditRecurrencePreFormAction.GetIntFormParameter(request, "selRcrYTI", defaultValue); int num = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtRcrMThM", 1); num = Math.Max(1, num); DaysOfWeek daysOfWeek = EditRecurrencePreFormAction.ParseDaysOfWeek(request, "selRcrThD", defaultDaysOfWeek); pattern = new MonthlyThRecurrencePattern(daysOfWeek, (RecurrenceOrderType)intFormParameter2, num); } } else { pattern = new WeeklyRecurrencePattern(DaysOfWeek.Weekdays); } if (newRecurrenceTypeFromPost != OwaRecurrenceType.None) { if (startDate == ExDateTime.MinValue) { startDate = CalendarUtilities.ParseDateTimeFromForm(request, "selSY", "selSM", "selSD", null, userContext); } RecurrenceRange range; switch (EditRecurrencePreFormAction.GetRecurrenceRangeTypeFromPost(request)) { case RecurrenceRangeType.Numbered: { int num3 = EditRecurrencePreFormAction.GetIntFormParameter(request, "txtno", 10); num3 = Math.Max(1, num3); range = new NumberedRecurrenceRange(startDate, num3); goto IL_284; } case RecurrenceRangeType.EndDate: { ExDateTime exDateTime = CalendarUtilities.ParseDateTimeFromForm(request, "selEY", "selEM", "selED", null, userContext); if (exDateTime < startDate) { exDateTime = startDate.IncrementDays(10); } range = new EndDateRecurrenceRange(startDate, exDateTime); goto IL_284; } } range = new NoEndRecurrenceRange(startDate); IL_284: result = new Recurrence(pattern, range); } return(result); }