[Simple-support] de/serializing class delegating read-only property.
Brought to you by:
niallg
|
From: N. N. <nju...@gm...> - 2009-03-31 04:00:57
|
how would one use SimpleXML to serialize/deserialize the following
prototypical example class? the basic premise is that the class delegates
some read-only properties to a subordinate class. the subordinate class, in
turn, must be initialized on instantiation (because its properties are
read-only).
i'd like to have the XML look something like <delegateProperty
propertyA="100" propertyB="200"/> (or as attributes) but can't figure out
how to appropriately annotate with SimpleXML. thanks for any help.
public class DelegatedProperty
{
public DelegatedProperty(int propertyA, int propertyB)
{
this.delegate = new Delegate(propertyA, propertyB);
}
public int getPropertyA()
{
return this.delegate.getA();
}
public int getPropertyB()
{
return this.delegate.getB();
}
private Delegate delegate = null;
}
|