ネストされたオブジェクトを直列化して、そのプロパティが親オブジェクトと同じレベルになるようにしたい(つまり、ネストされたタグではない)。具体的に:私はC#のオブジェクトがあります。ネストされたオブジェクトのXMLシリアル化がルートレベルで
[XmlRoot(ElementName="Root")]
public class TopLevel
{
public string topLevelProperty;
public NestedObject nestedObj;
}
public class NestedObject
{
string propetyOnNestedObject;
}
をし、私が望むようなXML:
<root>
<topLevelProperty>...</topLevelProperty>
<propertyOnNestedObject>...</propertyOnNestedObject>
<!--NOTE: propertyOnNestedObject would normally be inside a "<nested>" tag
but I'm trying to avoid that here-->
</root>
があることは可能ですか?