Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 RestSharp-WP7-无法将XML反序列化为列表_Windows Phone 7_C# 4.0_Deserialization_Restsharp - Fatal编程技术网

Windows phone 7 RestSharp-WP7-无法将XML反序列化为列表

Windows phone 7 RestSharp-WP7-无法将XML反序列化为列表,windows-phone-7,c#-4.0,deserialization,restsharp,Windows Phone 7,C# 4.0,Deserialization,Restsharp,我在WindowsPhone7.1项目中使用RestSharp 我这里有一个XML格式的响应: 我尝试将该响应反序列化到一个类: public class fullWall { public _user user { get; set; } public int numberOfFriend { get; set; } public int numberOfPhoto { get; set; } public List<timhotPhotos> t

我在WindowsPhone7.1项目中使用RestSharp

我这里有一个XML格式的响应:

我尝试将该响应反序列化到一个类:

public class fullWall
{
    public _user user { get; set; }
    public int numberOfFriend { get; set; }
    public int numberOfPhoto { get; set; }
    public List<timhotPhotos> timhotPhotos { get; set; }
    public fullWall()
    {
        timhotPhotos = new List<timhotPhotos>();
    }
}

我哪里错了?

您必须将默认的XML反序列化程序更改为
DotNetXmlDeserializer
,如下所示:

RestClient client;

client.AddHandler("application/xml", new DotNetXmlDeserializer());
public class fullWall
{
    public _user user { get; set; }
    public int numberOfFriend { get; set; }
    public int numberOfPhoto { get; set; }
    [System.Xml.Serialization.XmlElement()]
    public List<timhotPhotos> timhotPhotos { get; set; }
    public fullWall()
    {
        timhotPhotos = new List<timhotPhotos>();
    }
}
然后,将
xmlement
属性添加到
List-timhotPhotos
属性,如下所示:

RestClient client;

client.AddHandler("application/xml", new DotNetXmlDeserializer());
public class fullWall
{
    public _user user { get; set; }
    public int numberOfFriend { get; set; }
    public int numberOfPhoto { get; set; }
    [System.Xml.Serialization.XmlElement()]
    public List<timhotPhotos> timhotPhotos { get; set; }
    public fullWall()
    {
        timhotPhotos = new List<timhotPhotos>();
    }
}
public-class-fullWall
{
公共用户{get;set;}
public int numberOfFriend{get;set;}
public int numberOfPhoto{get;set;}
[System.Xml.Serialization.xmlement()]
公共列表{get;set;}
公众全墙(
{
timhotPhotos=新列表();
}
}

现在它应该可以正常工作了

我将编写几行代码将一些对象序列化为XML,然后检查生成的XML文件和XML文件之间的差异,尝试删除fullWall构造函数或删除timhotPhotos初始化