示例#1
0
文件: artist.cs 项目: passick/wp.fm
 /// <summary>
 /// artist.getInfo last.fm api function
 /// </summary>
 /// <param name="artistName">Artist name</param>
 /// <returns>Artist info object, containing artist desription</returns>
 public static async Task<artistInfo> getInfo(string artistName)
 {
     RequestParameters rParams = new RequestParameters("artist.getinfo");
     rParams.Add("artist", artistName);
     XDocument returnedXml = await Request.MakeRequest(rParams);
     if (Request.CheckStatus(returnedXml) == 0)
     {
         artistInfo artist = new artistInfo(returnedXml.Element("lfm").Element("artist"));
         return artist;
     }
     else
         throw new LastFmAPIException(returnedXml);
 }
示例#2
0
        private async void getArtistInfo(string artistName)
        {
            SystemTray.IsVisible = true;
            prog.IsVisible = true;
            prog.IsIndeterminate = true;
            prog.Text = "Loading...";

            try { currArtist = await artist.getInfo(artistName); }
            catch (TaskCanceledException) { }

            this.DataContext = currArtist;

            //NavigateToString method works bad with encodings, that's why I am using this stuff
            var store = IsolatedStorageFile.GetUserStoreForApplication();
            using (var stream = new IsolatedStorageFileStream("artist.html", FileMode.Create, FileAccess.Write, store))
            {
                using (var sw = new StreamWriter(stream))
                        sw.Write(utilities.makeHtmlFromCdata(currArtist.bio, currArtist.extralargeImage));
            }
            artistDescription.Navigate(new Uri("artist.html", UriKind.Relative));

            prog.IsIndeterminate = false;
            prog.IsVisible = false;
            SystemTray.IsVisible = false;
        }