Restsharp: XMLをリストに逆シリアル化できませんか?

作成日 2012年04月19日  ·  3コメント  ·  ソース: restsharp/RestSharp

こんにちは。WindowsPhone7.1プロジェクトでRestSharpを使用しています。

ここにXML形式の応答があります。
https://skydrive.live.com/redir.aspx?cid=0b39f4fbbb0489dd&resid=B39F4FBBB0489DD!139&parid = B39F4FBBB0489DD!103&authkey =!AOdT-FiS6Mw8v5Y

私はその応答をクラスに逆シリアル化しようとしました:

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>();
    }
}

ここに表示されているように、 timhotPhotosリストを除いて、すべてのプロパティに問題はありません。

GitHub Logo

timhotPhotosクラス:

public class timhotPhotos
{
    public string id { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public string url { get; set; }
    public double width { get; set; }
    public double height { get; set; }
    public DateTime createdDate { get; set; }
    public _user user { get; set; }
    public int numOfComment { get; set; }
    public int numOfRate { get; set; }
    public int numOfView { get; set; }
    public bool rated { get; set; }
}

私はどこが間違っていますか?

最も参考になるコメント

ああ、ありがとう :)

追伸:私は21歳の女の子です、はじめまして:)

全てのコメント3件

StackOverflowであなたの質問を見て、そこで返信しました。ここに私の返信をコピーします。

次のように、デフォルトのXMLデシリアライザーをDotNetXmlDeserializerに変更する必要があります。

RestClient client;

client.AddHandler("application/xml", new DotNetXmlDeserializer());

次に、XmlElement属性をリストに追加しますこのようなtimhotPhotosプロパティ:

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>();
    }
}

これで正常に動作するはずです。

そして、StackOverflowで回答を受け入れたので、この問題を解決します。 ;)

ああ、ありがとう :)

追伸:私は21歳の女の子です、はじめまして:)

このページは役に立ちましたか?
0 / 5 - 0 評価