[MUD-Dev] Serialization, dealing with changing classes.

Ammon Lauritzen ammon at simud.org
Wed Sep 4 17:13:12 CEST 2002


Neil Edwards wrote:

> Hi there, I am currently writing a MUD from scratch in C# for
> learning the language and I enjoy writing MUDs. I was wondering
> how people get round the problem of Serializing objects (to a
> file) who's class may change and make the serialized version
> unreadable.

In my limited experience with C#, I have never had problems with
serialized objects coming back as a different class than they
should... I actually quite enjoyed working with it. If for some odd
reason you play with wierd reflection stuff and cast things
around... you still have full access to everything in the
deserialized object. If you have trouble finding the specific
incantations required, I am sure I could dig up some of my code.

> I have tackled this problem previously with my java MUDs by
> writing XML based files and if something got removed from the
> class or added to it then the XML Parser would just not look for
> the item or give it a default if it didn't exist in the file. I
> was considering doing this again in C# but thought I would see how
> everyone else handled this.

Actually, there are two different serialization filters, classes
(whatever they call the bloody thing) in C#. One does the normal
binary dump, and one goes straight to XML. When deserializing, it
parses the XML flawlessly and you are good to go.

I might be asleep right now, but I am fairly confident that if what
I just said makes any sort of sense, it is true.

--
Ammon Lauritzen
http://www.simud.org/


_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list