I have a class with a number of fields which are normally calculated in the constructor from other data in the class. They are not serialized to XML because any changes to the rest of the data will likely require their recalculation.
Is there a way I can set up a function call to be triggered on deserialization?
What you are describing is
[OnDeserialized]XmlSerializerdoes not support serialization callback methods (at least, not in MS .NET; mono may be different). Depending on your needs, you could tryDataContractSerializerwhich does support serialization callbacks (as do a number of other serializers). Otherwise, your best approach may be to just have your own public method that you call manually.Another option is to manually implement
IXmlSerializable, but this is hard.