C# Restsharp和反序列化派生类型
考虑以下XML:C# Restsharp和反序列化派生类型,c#,xml,serialization,restsharp,C#,Xml,Serialization,Restsharp,考虑以下XML: <events xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" artist="Rammstein" festivalsonly="0" page="1" perPage="50" totalPages="1" total="25"> <event xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"> <id
<events xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" artist="Rammstein" festivalsonly="0" page="1" perPage="50" totalPages="1" total="25">
<event xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<id>1985967</id>
<title>Rammstein: "Made in Germany 1995 -2011 LIVE"</title>
<artists>
<artist>Rammstein</artist>
<artist>Deathstars</artist>
<headliner>Rammstein</headliner>
</artists>
</event>
</events>
我希望最后能有一个包含3个项目的列表,这里有两个艺术家和一个头条,但我只得到艺术家。有没有可能让这种行为在Restsharp中开箱即用?还是需要自定义序列化程序
使用attributes,我想我需要xmlclude属性,但到目前为止我喜欢Restsharp的“开箱即用”部分。从你发表文章的日期起,我可能有点晚了,但晚了总比没有好 我认为您的xml需要更像这样:
<events xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" artist="Rammstein" festivalsonly="0" page="1" perPage="50" totalPages="1" total="25">
<event xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<id>1985967</id>
<title>Rammstein: "Made in Germany 1995 -2011 LIVE"</title>
<artists>
<artist>Rammstein</artist>
<artist>Deathstars</artist>
<artist xsi:type="headliner">Rammstein</artist>
</artists>
</event>
</events>
这是有道理的,但遗憾的是,我不是XML的供应商
<events xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" artist="Rammstein" festivalsonly="0" page="1" perPage="50" totalPages="1" total="25">
<event xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<id>1985967</id>
<title>Rammstein: "Made in Germany 1995 -2011 LIVE"</title>
<artists>
<artist>Rammstein</artist>
<artist>Deathstars</artist>
<artist xsi:type="headliner">Rammstein</artist>
</artists>
</event>
</events>