2

I just stumbled across OnDeserializedAttribute on MSDN. The description states

When applied to a method, specifies that the method is called immediately after deserialization of an object in an object graph. The order of deserialization relative to other objects in the graph is non-deterministic.

Questions

  1. Is a method with this attribute called for any serializer?
  2. If so, how does .NET ensure the method is called for an arbitrary serializer?
  3. If not, is it supported for all of the "common" serializers (BinaryFormatter, XmlSerializer, JSON Serializer, DataContractSerializer)?
Eric J.
  • 147,927
  • 63
  • 340
  • 553

1 Answers1

3
  1. No. It does not work on the XmlSerializer.
  2. It doesn't do any enforcement. It's an "opt-in" functionality for a serializer.
  3. It does work on BinaryFormatter and DataContractSerializer.
Community
  • 1
  • 1
vcsjones
  • 138,677
  • 31
  • 291
  • 286