Hi All,
I am having trouble finding documentation on copying/cloning an AppointmentRecurrence. In our application, the user creates an Appointment and specifies the recurrence pattern. We store the AppointmentRecurrence in the database using Save() and restore it using FromBytes().
Now the user wants to copy that appointment as a new appointment. I found out the hard way that when you simply copy the original AppointmentRecurrence, it does not work because the objects will have the same GUID, and the CalendarInfo class will see them as duplicates causing weird problems.
Of course, I could manually create a new AppointmentRecurrence and copy each value, but there should be a better way.
I see there is a method InitializeFrom() available, but there is little documentation that I can find. Is this the proper way to clone an AppointmentRecurrence? How have you handled this?
Update:
When I copy the Byte[] obtained from .Save() to the new appointment, setting the "isRemoved" flag will sometimes set the incorrect occurrence (Setting it on the original appointment will actually set it on the child occurrence.). I assumed this was because of the duplicate ID. (The appointments were correctly assigned)
When I use the Initialize From() method to clone the recurrence, I still have two Recurrence objects with the same ID, but the modifying of the Occurrences appears to work correctly.
Can someone from Infragistics confirm why this is and if Initialize From is the correct way to clone. I am nervous about the duplicate ID's, but there is no way to change it since there is no setter.
Thanks,
Mark
Hello Mark,
Thank you for contacting Infragistics!
Is there a reason you are creating a copy of the recurrence instead of the appointment itself? InitailzeForm is used for serialization.