Hi Dino,
I have tried your second solution and it works - I created a boolean -
IdSpecified - in the base class set to true and then set it to false
in the constructor of the derived class. This hid the Id property from
serialisation.
However, the solution we are going with is to have all base members set
to XmlIgnore and then override them in the derived class. As the body
of the derived class is also initially generated, all fields will be
overriden so that they are exposed. Then, to hide a member, we simply
delete it from the derived class.
This also helps with changing a property's type in the derived class
(serialisation fails if a property is hiding an inherited property with
a different type) as it will not build unless you delete the generated
overriden property in the derived class.
I still think you should be able to hide an inherited property from the
derived class without manipulating the base class.
Thanks,
Rob
Dino Chiesa [Microsoft] - 22 Feb 2005 22:27 GMT
Glad to hear you succeeded.
This gets better in .NET 2.0, and better again in Indigo.
Another approach is to use attribute overrides. You can dynamically
generate attributes to hide and expose what you want.
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxmlserializationxm
lattributeoverridesclasstopic.asp
I can imagine reflecting on all the properties of a type (inherited or not)
and applying attributes on each one. . .
-D
> Hi Dino,
>
[quoted text clipped - 20 lines]
>
> Rob