Click to See Complete Forum and Search --> : Serialization


Luxx
January 3rd, 2009, 06:20 AM
Abstract class: X
Child classes of X: A, B, C

Multiple instances of child classes in a generic list, which is populated by a Register method..

..
Register( new A( 1 ) );
Register( new A( 2 ) );
Register( new B( 1 ) );
...


The child classes must be constructed during this part of the code. I don't want to construct them while serializing (ie: I save the type and instantiate it). The problem in doing so would be that while I know what type of class I am loading, I don't know if it's properties 1 or 2.

I have a generic Serialize scheme which iterates through the list; doesn't give any issues long as the ordering in the list is the same when loading. In the future, I will likely have a different order (additions, removals, etc..), which will cause a conflict when loading the serialized information.

How would I be able to handle this type of serialization? or How can I identify the serialized information for each class instance?