0
考虑下面的XML:Restsharp和反序列化派生类型
<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>
我想反序列化artists
下的所有标签为一个单独的列表。我有什么至今:
public class Artist
{
public string Value { get; set; }
}
public class HeadLiner : Artist
{
}
public class ArtistCollection : List<Artist>
{
}
public class Event
{
public ArtistCollection Artists { get; set; }
}
我希望用含有此3项(两位艺术家和一个顶篷)的列表来结束,但我只得到了艺术家。使用Restsharp可以获得这种行为吗?或者我需要一个自定义串行器?
使用属性,我想我需要XmlInclude
属性,但是我非常喜欢Restharp的“开箱即用”部分。
这是有道理的,但遗憾的是我不是XML的供应商 – diggingforfire 2012-04-27 17:38:32