Set NonSerialized() at Run Time

  • Thread starter Thread starter Marty Cruise
  • Start date Start date
M

Marty Cruise

There are some cases where I do not want to serialize
certain properties of a class. Can I set individual
properties as NonSerialized() at run-time?
 
Marty,
The only way I know of is to implement the ISerializable interface and do
all the work yourself.

If you don't have them the following articles covers every thing you wanted
to know about serialization but were afraid to ask:

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Including how to implement the ISerializable interface, and the special
constructor needed.

Hope this helps
Jay
 
Hi Marty,

Those articles that Jay referred to are a useful read.

There is possibly a way to do what you want by investigating the Attribute
classes and having a fiddle about there. I wouldn't fancy that route myself
until I read the corresponding articles on Attributes!

If implementing your own ISerialize seems daunting, however, I have a
glimpse of an idea for a
a workaround. I haven't thought it out and it would depend on what properties
you are talking about and in which circumstances, etc.

Rather than go into the idea with no information, I'll wait and see if the
articles give you a path to follow. I'm more the straw, to Jay's life-jacket!
;-)

Regards,
Fergus
 
Back
Top