Custom Appointment Subclass

4 posts, 1 answers
  1. Eve Cunning
    Eve Cunning avatar
    14 posts
    Member since:
    Oct 2009

    Posted 26 Feb 2010 Link to this post

    Hello,

    I've spent the past few days trying to subclass Appointment to add additional data properties to it, but to no avail.  (We need to add a dynamic list of string int pairs to the Appointment, which, since they are dynamic, can't be done with the standard declarative attributes set).

    So, on my subclass, I overrode Clone, the deserialization constructor and GetObjectData, LoadViewState, and SaveViewState, and created an appropriate AppointmentFactory for the scheduler to use.  However, my additional data values were never making it back to the Insert or Update call on my provider.

    Having a look at the code using Reflector, I see that my values are likely getting lost during the internal call to LoadFromDictionary.  There are no virtual functions there for me to inject my data values into the load, so they are never getting restored.

    So, just for my own sanity, I wanted to confirm that yes, given the way Scheduler is currently written, subclassing Appointment in this way is impossible, and it's okay to stop trying to make this work.  :)

    I am going to fall back and use one of the standard attributes as a delimited string of the values, but I was hoping for the more elegant solution.

    Best regards,
    Eve
  2. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2817 posts

    Posted 02 Mar 2010 Link to this post

    Hello Eve,

    I've tested this scenario and the only problem I see is that the base ISerializable implementation does not process the properties in the inherited implementation. To make things worse,  the GetObjectData method is implemented explicitly. Serializing custom fields thus requires completely rewriting it.

    So, we've changed two things in the latest internal build:
    1. Appointment ISerializable implementation now processes properties in inherited classes
    2. The GetObjectData is now a protected virtual method

    I'm sending you a sample project (with the latest assembly version) that demonstrates that using dictionaries is now easily doable.

    We'll consider if the LoadFromDictionary method should be made virtual too, but for this scenario this is not a problem.

    I hope this helps.

    Kind regards,
    Tsvetomir Tsonev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Eve Cunning
    Eve Cunning avatar
    14 posts
    Member since:
    Oct 2009

    Posted 02 Mar 2010 Link to this post

    Thank you, Tsvetomir!  This is perfect.

    It was a long journey to try to get the custom subclass to work, then only to find that it would never work.  I am so glad to get this fix!

    Best regards,
    Eve
  4. Jeff
    Jeff avatar
    10 posts
    Member since:
    Sep 2010

    Posted 15 May 2012 Link to this post

    @Tsvetomir  

    Would we be able to do something similar with a WCF Web Service datasource and custom provider?


Back to Top