I need to maintain certain data structure, shared by all instances of
a class, declared as [Serializable]. This data structure must change
whenever a new object is created or an existing object is destroyed.
So I declared a static field with [NonSerialized()] attribute.
Now I need to add some code into all places where objects are created
and destroyed. This class has 2 ctors: one default, and another taking
parameters. I've found out, to my surprise, that new instances are
created without the use of these 2 ctors (how?).
My question: where should I put my code that tracks object creation
and destruction for these serializable objects?