I have generic base class which has property body and another derived class which has property header and when i deserialize the derived class into xml its placing the body as first element first then header (deserializing in alphabetical order) but I want header first and then Body. I have tried XmlElement's order property but its not working
Sample class:
[XmlRoot("BaseClass", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class BaseClass<T>
{
public T Body { get; set; }
}
[XmlRoot("DerivedClass", Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class DerivedClass<THeader, TBody> : BaseClass<TBody>
where THeader : IEnvelopeHeader where TBody : class, IEnvelopeBody, new()
{
public THeader Header { get; set; }
}
I saw one solution which says that make the property in base class as abstract and override in derived class then decide the order but i cann't go with this solution which my base class is used in some other projects as well.