I need to save my model into XML and later read it back.
I’m using the ‘MakeXElement’ and ‘LoadFromXElement’ from the samples.
All of my string attributes are saving fine but I’m stuck with how convert a ‘Spot’ into XML and read it back.
My Spot property:
public Spot OBJECT_SPOT
{
get { return _oBJECT_SPOT; }
set
{
if (_oBJECT_SPOT != value)
{
Spot old = _oBJECT_SPOT;
_oBJECT_SPOT = value;
RaisePropertyChanged("OBJECT_SPOT", old, value);
}
}
}
private Spot _oBJECT_SPOT = Spot.None;
I’m trying to accomplish something like this (but it’s not working):
public override XElement MakeXElement(XName n)
{
XElement e = base.MakeXElement(n);
.....
<b>e.Add(XHelper.Attribute("OBJECT_SPOT", this.OBJECT_SPOT, new Spot(0,0)));</b>
.....
return e;
}
public override void LoadFromXElement(XElement e)
{
base.LoadFromXElement(e);
.....
<b>this.OBJECT_SPOT = XHelper.Read("OBJECT_SPOT", e, "");</b>
.....
}
Any ideas?