I have a Point class which I want to serialize as attribute. Here is the example of what I really want:
public class PointXY
{
[XmlIgnore]
public Double X { get; set; }
[XmlIgnore]
public Double Y { get; set; }
public override string ToString()
{
return Points;
}
}
public class TestClass
{
[XmlAttribute]
public PointXY Points { get; set; }
}
The Test Class should be serialized to:
<TestClass Points="0.1 0.2">
</TestClass>
I know this can be achieved if TestClass is implemented using IXmlSerializable interface. But what I want PointsXY should emmit itself as attribute instead of element. Is it possible? If yes how? This should get deserialized as well.