Xml Serialization + Dynamic Element Name

I want to know if it is possible to change the base of the element name under 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; } } 
+4
source share
1 answer

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

+3
source

All Articles