XmlIgnore an inherited attribute

B

bg_ie

Hi,

I have a number of classes that inherit from another class which
contains an attribure called "Url". I serialise my objects to an xml
file, but I would like to hide the "url" attribute for one of my
inherited classes. I can place the XmlIgnore in the base class, but
this will hide the attribute for all derived class. What should I do?

Thanks,

Barry.
 
M

Marc Gravell

You could try adding a "bool ShouldSerializeUrl()" method; this is a
pattern (like "event EventHandler UrlChanged") recognised by various
parts of the core framework.

If you have inheritance, though, you may need to do this at the base
class (return true), and then override in the subclass (return false).

Marc
 
M

Marc Gravell

You could try adding a "bool ShouldSerializeUrl()" method; this is a
pattern (like "event EventHandler UrlChanged") recognised by various
parts of the core framework.

If you have inheritance, though, you may need to do this at the base
class (return true), and then override in the subclass (return false).

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top