views:

23

answers:

1

I want to know if it is possible to change the element name base on some condition... something like this:

[XmlRoot(ElementName=BaseEntity.useShortTag==false?"a0912":"Product")]
public class Product : ONIX.Entities.BaseEntity
{
    public Product()
    {

    }

    public string RecordReference { get; set; }
}
A: 

No, this is not possible using attributes because they are evaluated at compile time. The only way to achieve this is to make your class implement IXmlSerializable and handle the serialization manually.

Darin Dimitrov