This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I want to save/load a Scheduler, which has an inherited class of ScheduleItem, namely ColoredScheduleItem. According to the API document, it seems that the only ScheduleItem type objects are serialized. I can't get a clue for doing this. Many thanks for the comment. Hobin |
|
|
Hello Hobin Here is the code example from the documentation:
To serialize custom schedule item implementations, you can modify this code to include the additional property values that need to be serialized on ColoredScheduleItem. If you have several different custom implementations, you can use conditional statements to serialize the different properties. In the code above, we have used the Select method to iterate through the Schedule items. You should change this to be a standard for-loop so you can cast each item to access the custom properties. Let me know if you have further questions. Jason Fauchelle |
|
|
Dear Jason, Thank you for the comment. I have another question. Assuming that I have a ColoredScheduleItem which is inherited from the class ScheduleItem, there's no problem on reading items with the code
However, in case of writing, schedule.Items.Select() seems that it does not enumerate ColoredScheduleItems. What should I do? Hobin |
|
|
Hello Hobin I recommend trying to write the elements without using the Select method. Instead, use a for loop. Let me know if you need more help. Jason Fauchelle |
|
|
Okay. Would you teach me more specific? :-) Thank you! |
|
|
Hello Hobin Here is a simple way of doing it without changing the existing code sample much. This worked well in my colored-schedule-item application:
Here I have added a line that checks to see if the schedule item is actually a colored-schedule-item. If so, it saves the color to the xml document. In this case my Color property is of type Color, so this code saves the ToString result which is the hex encoding of the color. The Select method does successfully traverse all items, including the custom colored-schedule-item implementations. Let me know if there are still issues and I'll help you out. Jason Fauchelle |
|