I need to know when a child object is currently deserialized using the Microsoft XmlSerializer.
I do not want to use a global indicator which would not works in multithread.
My class is already automatically deserialized using public properties. I prefer to not manage serialization myself (I prefer to stay with automatic deserialization of public properties if possible).
I thought about 2 things:
- Using TLS (ie Thread local storage - because XmlSerializer is single threaded)
- Using the CallStack
But both approach are far from being elegant. I wonder if there is not a better solution like implementing a Deserializable interface or something else? I'm missing knowledge to know how to do it in a clean way.