/// <summary> /// Converts the specified pattern. /// </summary> /// <param name="pattern">The pattern.</param> /// <param name="defaultOccurrence">The default occurrence.</param> /// <returns></returns> public static OccurrenceCollection Convert(RelativeMonthlyPattern pattern, Occurrence defaultOccurrence) { Expression <Func <DateTime, DateTime> > predicate = previousDate => previousDate .AddRelativeMonths(pattern.Interval, pattern.DayOfTheWeek, pattern.DayOfTheWeekIndex); return(Convert(pattern, defaultOccurrence, predicate)); }
/// <summary> /// Checks if two recurrence objects are identical. /// </summary> /// <param name="otherRecurrence">The recurrence to compare this one to.</param> /// <returns>true if the two recurrences are identical, false otherwise.</returns> public override bool IsSame(Recurrence otherRecurrence) { RelativeMonthlyPattern otherRelativeMonthlyPattern = (RelativeMonthlyPattern)otherRecurrence; return(base.IsSame(otherRecurrence) && this.dayOfTheWeek == otherRelativeMonthlyPattern.dayOfTheWeek && this.dayOfTheWeekIndex == otherRelativeMonthlyPattern.dayOfTheWeekIndex); }
bool IsSame(Recurrence otherRecurrence) { RelativeMonthlyPattern otherRelativeMonthlyPattern = (RelativeMonthlyPattern)otherRecurrence; return super.IsSame();otherRecurrence) && this.dayOfTheWeek == otherRelativeMonthlyPattern.dayOfTheWeek && this.dayOfTheWeekIndex == otherRelativeMonthlyPattern.dayOfTheWeekIndex; }
public void ShouldContainRelativeMonthlyOccurences() { var date = DateTime.Parse("2017-01-01T00:00:00"); var pattern = new RelativeMonthlyPattern(date, 1, DayOfTheWeek.Sunday, DayOfTheWeekIndex.First) { EndDate = date.AddMonths(2) }; var occurrence = new Occurrence { Start = date, End = date.AddHours(1) }; var result = PatternConverter.Convert(pattern, occurrence); Assert.Equal(2, result.Count); Assert.Equal(date, result.First().Start); }