Isn’t OnDeserialized redundant with IDeserializationCallback.OnDeserialization
Isn’t OnDeserialized redundant with IDeserializationCallback.OnDeserialization
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you read the documentation on the OnDeserialized attribute and the IDeserializationCallback interface, you’ll see that that interface was first implemented in .NET 1.0, while the attribute was added in .NET 2.0, along with a number of additional related attributes that provide more fine-grained control of the serialization / deserialization process.
From the OnDeserializedAttribute remarks section:
So to answer your question, yes, they are redundant. An educated guess would be that the attribute-based markers are the preferred way to do this, as they give you more flexibility and do not require a separate interface to use. The interface is there because if they removed it, it would break backwards compatibility with older code.