Normally in C# Xml types are marked with attributes to define the way how they get serialized:
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace=
"urn:xmlns:25hoursaday-com:my-bookshelf")]
public class bookType {
/// <remarks/>
public string title;
/// <remarks/>
public string author;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("publication-date",
DataType="date")]
public System.DateTime publicationdate;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string publisher;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("on-loan")]
public string onloan;
}
Now when it comes to the point that I like to use POCOS without these attributes that I could potentially reuse to do an OR-Mapping with e.g. NHibernate, then it would be nice to define the serialization way in a manner without altering the types to be serialized.
The question is: Is there a way to declerativeley define the way a type gets serialized by e.g.: a mapping xml file.