Re: Code serialization order

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello Arjun,

I'm afraid you should change something in the object design.
Not because it is invalid, but because MS/VS can not fitt all
imaginable requirements/wishes.

The VS Serializer (i suppose) considers
IComponents as serialization "roots". It starts with Components
and serializes recursively objects that are "used" by them.
An object is considered to be "used", if it is an argument of a ctor,
a value of a read/write property, a member of an ICollection, etc.
What "using" means can be specified more precise by different
attributes.

I do not understand the reason why the Serializer serializes
"object2" in your example. That is why i can hardly understand
what is "thinks" doing this and how to "convince" it to act
differently.

May it be, that "object2" is used by another component
(one different from "object1") ?
I suppose, there must be somewhere an "owner" of object2
that has a rank of a Component and serializing obvject2
is a consequence.

If I new more about your example.

Another idea were to implement all Wrappers as an extension
properties of some IExtenderProvider. In this case the VS Serializer
knows what to do and serializes in a correct order.

Regards,
Dima.

.