Hello overflow,
our task is quite simple, we have an object graph where each object (IDItem) has a unique ID. The object graph exists two times, on the client and on the server machine.
Now we pass some serializable commands to the server. The command has as fields some of the IDItems. The IDItems implement the ISerializable interface and only store their ID in the SerializationInfo. Like:
// The method called when serializing a IDItem.
void GetObjectData(SerializationInfo info, StreamingContext context)
{
// Instead of serializing this object, just save the ID
info.AddValue("ID", this.GetID());
}
The problem is, how can we assign the existing object to the instance that the deserializer creates? Obviously something like the following in the ISerializable constructor does not work, because the 'this' identifier is read only:
//does not work
protected IDItem(SerializationInfo info, StreamingContext context)
{
this = GlobalObject.GetIDItem(info.GetString("ID"));
}
So any idea how we can Assign an existing object to the deserialized object?
Best Regards, thalm