views:

15

answers:

1

I have a bunch of classes that I intend to serialize in order to transport over a webservice call.

These classes already have properties that return whether a given "real" property has a value or not, that is ingrained in a lot of code of our product.

Is it possible, for instance through attributes, for me to specify that each "real" property should be included if a specified other property returns true, but not one that is called RealPropertyNameSpecified?

ie. for instance if I have this class:

[XmlType("test")]
public class TestClass
{
    [XmlIgnore]
    public bool NameHasGotAValue { get; set; }

    [XmlElement("name")]
    public string Name { get; set; }
}

Is it possible for me to use the NameHasGotAValue as the "*Specified" method for the Name property, or is my only option to either rename NameHasGotAValue, add a NameSpecified method, or implement IXmlSerializable?

A: 

HI,

For my knowledge, in order to satisfy you requisites, the implementation of the interface iXMLSerializable is the best solution.

Marcello Faga