Using restsharp in c# to consume last.fm services
I'm trying to connect to the last.fm rest services using restsharp. I can deserialize the simple data found at the example: http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Cher&api_key=xxxxxxxxxxxxxxxxxxxxxxx
however, when i reach the images section for the artist:
<artist>
<name>Cher</name>
<mbid>bfcc6d75-a6a5-4bc6-8282-47aec8531818</mbid>
<url>http://www.last.fm/music/Cher</url>
<image size="small">http://userserve-ak.last.fm/serve/34/48511693.png</image>
<image size="medium">http://userserve-ak.last.fm/serve/64/48511693.png</image>
<image size="large">http://userserve-ak.last.fm/serve/126/48511693.png</image>
<image size="extralarge">http://userserve-ak.last.fm/serve/252/48511693.png</image>
<image size="mega">http://userserve-ak.last.fm/serve/500/48511693/Cher+Tess.png</image>
i am struggling to get the library to map the data. Here is the code I have so far:
namespace *******.Core.LastFm
{
using System.Xml.Serialization;
using System.Collections.Generic;
using System;
public class image
{
[XmlAttribute]
public string Size { get; set; }
public 开发者_如何学编程string Value { get; set; }
}
public class ArtistImageCollection : List<image> { }
public class Artist
{
public string Name { get; set; }
public string Mbid { get; set; }
public string Url { get; set; }
[XmlArray]
public ArtistImageCollection Image;
}
}
this doesnt work. does anyone know how to bind this?
[i updated it to reflect nics suggestion - this doesn't work still]
i got the basis for this code from: http://www.aaronstannard.com/post/2010/06/14/How-to-Parse-a-Users-Delicious-Feed-with-RestSharp.aspx
w://
there was no get/set on Image
doh
Dont you need to annotate the Size with [Attribute] and Image with [XmlArray] or something weird like that?
精彩评论