When I serialize;
public class SpeedDial { public string Value { get; set; } public string TextTR { get; set; } public string TextEN { get; set; } public string IconId { get; set; } }
It results:
<SpeedDial> <Value>110</Value> <TextTR>Yangın</TextTR> <TextEN>Fire</TextEN> <IconId>39</IconId> </SpeedDial>
But what I want is this:
<speedDial> <value>110</value> <text> <TR>Yangın</TR> <EN>Fire</EN> </text> <iconId>39</iconId> </speedDial>
I want to learn the canonical way…
Three approaches leap to mind:
1: create a property to use for the serialization, and hide the others with
[XmlIgnore]2: implementIXmlSerializableand do it yourself 3: create a separate DTO just for the serializationHere’s an example that re-factors the ‘text’ portion into objects that
XmlSerializerwill like, while retaining the original public AIP: