serialization - Custom serializer and inheritence in C# -
i'm learning serialization in c# , have basics down, trying little more complicated , i'm looking pointers on best practice (i can achieve want, want know 'right'/easiest/least code/most robust method of doing it).
i have racing track made of sections. each section type inherits common tracksection class. tracksection class holds lot of data on geometry , other things don't want save out , needs context information when constructor called, have implemented iserializable interface , provided own methods handle (de)serialization. classes inherit tracksection lot simpler, , happy fields serialized automatically, assume since base class iserializable need manually (i have added deserialization constructor , call base class's deserialization constructor in each). when comes serializing though i'm not sure do, have expected iserializable's getobjectdata() method virtual extend serialization in sub-classes. need implement own virtual method called base class's getobjectdata(), or going wrong?
as say, have working better solution or general tips i'm doing appreciated, can't feel solution little more complicated needs be. thanks.
unless you're doing need implement iserializable, could, instead mark class serializable attribute , mark fields don't want serialized nonserialized
Comments
Post a Comment