XmlAttributeOverrides with Custom Attributes?

A

ASwanevelder

Dear All,

I really enjoy the cleaness of using the build in Serialization of .NET. Now I am sitting with a dillema. I need to limit the Properties serialized in certain cases. Now the preposed way of doing this according to the MSDN is to use the XmlSerializer class and using Serialize and Deserialize on that class and customize the attributes with the XmlAttributeOverrides class. I think this is really messy and in my arhitecture I do not want people to write custom handlers to serialize and deserialize.

Is there not a way that I can write a Custom Attribute that can be attached to these properties that take in an XmlAttributeOverrides instance into its contructor and then from that tell the XmlAttributes.XmlIgnore attribute to be true or false? Can you somehow access the XmlAttributes.XmlIgnore from within a Custom Attribute.

PSEUDO:

[CustomXmlIgnore(XmlAttributeOverrides)]
public int Parameters
{
get;
set;
}

class CustomXmlIgnore: Attribute
{
CustomXmlIgnore(XmlAttributeOverrides)
{
Loop through all the Attributes overrides
{
if (attribute equals CustomXmlIgnore and XmlIgnore)
set XmlAttributes.XmlIgnore accordingly
}
}
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top