Free Support Forum - aspose.com

Comparing Recurrence Patterns

Is there a way to compare two RecurrencePattern objects to see if they are the same pattern?

Here's is my testing scenerio in C#:

1. I've created two (2) RecurrencePattern objects and loaded the object with the exact same pattern via the .FromiCalendar method. NOTE: I am using the demo version of iCalendar for evaluation purposes.

RecurrencePattern patternInit = RecurrencePattern.FromiCalendar("DTSTART:20040101T233000\r\nRRULE:FREQ=DAILY");

RecurrencePattern patternUpdated = RecurrencePattern.FromiCalendar("DTSTART:20040101T233000\r\nRRULE:FREQ=DAILY");

2. When I evaluate the 2 object together, the evaluation returns false when I'm expecting true since the objects are implementing the same pattern.

? patternInit == patternUpdated

false

3. When I evaluate the 2 object together using the .Equals() method, the evaluation returns false when I'm expecting true since the objects are implementing the same pattern.

? patternInit.Equals(patternUpdated)

false

4. When I evaluate the objects via the .ToiCalendar() method, they evaluate to true.

? patternInit.ToiCalendar() == patternUpdated.ToiCalendar()

true

Is using the .ToiCalendar() method the correct/preferred/best way to evaluate if two Recurrence Patterns are the same or should the RecurrencePattern objects be comparable?

Any insight would be helpful and thanks in advance for any responses.

Hi,

>> patternInit == patternUpdated - false
>> patternInit.Equals(patternUpdated) - false

Aspose.iCalendar does not override "Equals" and "==".
The default implementation of these operators supports reference equality only, that is, whether the references refer to the same object.

>> patternInit.ToiCalendar() == patternUpdated.ToiCalendar() - true

Aspose.iCalendar.ToiCalendar() returns the recurrence pattern as a string in iCalendar format.
It is an only way to compare Aspose.iCalendar objects values.