What is the deserialization equivalent of ISerializable.GetObjectData?

I am writing a special serializer, and I just finished implementing the part for processing ISerializable.GetObjectData . But when I proceed to deserialize the information and apply it to the graph again, I don’t see the equivalent function for Set -ObjectData.

How can I reapply SerializationInfo data to a chart?

+4
source share
1 answer

Implement the special deserialization constructor as described in the MSDN library documentation for ISerializable :

The ISerializable interface implies a constructor with a signature constructor (SerializationInfo information, StreamingContext context). At the time of deserialization, the current constructor is called only after the data in SerializationInfo has been deserialized by formatting. In general, this constructor should be protected if the class is not sealed.

For instance:

 protected Widget(SerializationInfo info, StreamingContext context) { // Perform your deserialization here... this.SerialNumber = (string)info.GetValue("SerialNumber", typeof(string)); } 
+4
source

Source: https://habr.com/ru/post/1479025/


All Articles