1
这应该很简单,但显然我错过了这个诀窍。我有一个POCO:如何序列化具有所需属性名称的POCO
public class job
{
public string title { get; set; }
public string company { get; set; }
public string companywebsite { get; set; }
public string[] locations { get; set; }
}
我使用RestSharp将它序列化为XML。我希望能得到两种:
<job>
<title>Hello title</title>
<company>Hello company</company>
<locations>New York</locations>
<locations>Los Angeles</locations>
<locations>Detroit</locations>
</job>
或理想...
<job>
<title>Hello title</title>
<company>Hello company</company>
<locations>
<location>New York</location>
<location>Los Angeles</location>
<location>Detroit</location>
</locations>
</job>
但是相反正在此:
<job>
<title>Hello title</title>
<company>Hello company</company>
<locations>
<String />
<String />
<String />
</locations>
</job>
显然,POCO需要是不同的。我能做什么?
是否RestSharp行为方式作为框架的XmlSerializer的一样吗? – phoog 2012-02-22 22:09:58
如果它不它可能应该;) – dice 2012-02-22 22:32:54
谢谢,这没有解决RestSharp问题,但我刚回到框架版本和您的建议工作。 – 2012-02-22 22:50:24