Serializing inherited objects
From: Mark Saccomandi (mark.saccomandi_at_a.team.nu)
Date: 09/08/04
- Next message: Niki Estner: "Re: Meaning of Double.Epsilon"
- Previous message: Klaus Bonadt: "Re: How to retrieve serial number of OS or CPU for copy protection?"
- Next in thread: Marcin Grzębski: "Re: Serializing inherited objects"
- Reply: Marcin Grzębski: "Re: Serializing inherited objects"
- Reply: Patrik Löwendahl [C# MVP]: "Re: Serializing inherited objects"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: Serializing inherited objects"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 8 Sep 2004 10:49:02 +0200
Hi,
I'm extending a serializable class I made. The new class adds some features
that cannot be serialized automatically, this means that I have to implement
the ISerializable interface for my new class. What happens is that I do
serialize what I have written within the GetObjectData method, but now I do
not get to automatically serialize the data from my parent class.
Is there a way to serialize automatically the properties from my parent
class and then to serialize manually only what I have added in the derived
class?
Here's a sample of the code:
[Serializable]
public class OperDataSocketIn : Operator, ISerializable
{
[NonSerialized]
private DataSocket dataSocketIn;
...
private OperDataSocketIn( SerializationInfo info, StreamingContext
context)
{
dataSocketIn =new DataSocket();
dataSocketIn.Url= info.GetString("Url");
}
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
{
info.AddValue("Url", dataSocketIn.Url);
}
...
}
Using this code after deserializing I get an object that has empty values
except for dataSocketIn.Url.
Thanks, Mark Saccomandi
- Next message: Niki Estner: "Re: Meaning of Double.Epsilon"
- Previous message: Klaus Bonadt: "Re: How to retrieve serial number of OS or CPU for copy protection?"
- Next in thread: Marcin Grzębski: "Re: Serializing inherited objects"
- Reply: Marcin Grzębski: "Re: Serializing inherited objects"
- Reply: Patrik Löwendahl [C# MVP]: "Re: Serializing inherited objects"
- Reply: Nicholas Paldino [.NET/C# MVP]: "Re: Serializing inherited objects"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|