serializing type definitions?

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-04-29T00:09:56Z Indexed on 2010/04/29 0:17 UTC
Read the original article Hit count: 618

I'm not positive I'm going about this the right way. I've got a suite of applications that have varying types of output (custom defined types).

For example, I might have a type called Widget:

Class Widget
      Public name as String
End Class

Throughout the course of operation, when a user experiences a certain condition, the application will take that output instance of widget that user received, serialize it, and log it to the database noting the name of the type.

Now, I have other applications that do something similar, but instead of dealing with Widget, it could be some totally random other type with different attributes, but again I serialize the instance, log it to the db, and note the name of the type. I have maybe a half dozen different types and don't anticipate too many additional ones in the future.

After all this is said and done, I have an admin interface that looks through these logs, and has the ability for the user to view the contents of this data thats been logged. The Admin app has a reference to all the types involved, and with some basic switch case logic hinged upon the name of the type, will cast it into their original types, and pass it on to some handlers that have basic display logic to spit the data back out in a readable format (one display handler for each type)

NOW... all this is well and good...

Until one day, my model changed. The Widget class now has deprecated the name attribute and added on a bunch of other attributes. I will of course get type mismatches in the admin side when I try to reconstitute this data.

I was wondering if there was some way, at runtime, i could perhaps reflect through my code and get a snapshot of the type definition at that precise moment, serialize it, and store it along with the data so that I could somehow use this to reconstitute it in the future?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about serialization