I have some problem with serialization an object to XML. At the beggining, this is class Order which have some properties of types like string, int...
public class Order
{
[XmlAttribute("ObjectType")]
public string TypeName
{
get; set;
}
[XmlAttribute("ID")]
public string ID
{
get; set;
}
[XmlAttribute("TID")]
public string TID
{
get; set;
}
[XmlAttribute("Command")]
public Command Command
{
get; set;
}
public Order()
{
}
}
As you can see, this class has also one property of type Command. Command class has one property of type string called Name:
public class Command
{
[XmlAttribute("Name")]
public string Name
{
get; set;
}
}
What's the problem? I need to get result like this:
<Order ObjectType="TestCase" ID="2" TID="W404" Command="SomeCommand" />
Where 'SomeCommand' is value of 'Name' property of this Command object.
With simple words: i need to define behave of how Command object should be serialized to XML attribute - return Name string. Very important thing is that also I have to be able to deserialize this XML to objects structure.
Hope my post is understandable and my problem is explained clearly. ;)
Best regards!
No comments:
Post a Comment