Ejemplo n.º 1
0
 public static ArtistBrowseType ConvertBack(ArtistBrowsingType type)
 {
     ArtistBrowseType artistBrowseType;
     switch (type)
     {
         case ArtistBrowsingType.Full:
             artistBrowseType = ArtistBrowseType.Full;
             break;
         case ArtistBrowsingType.NoAlbums:
             artistBrowseType = ArtistBrowseType.NoAlbums;
             break;
         case ArtistBrowsingType.NoTracks:
             artistBrowseType = ArtistBrowseType.NoTracks;
             break;
         default:
             artistBrowseType = ArtistBrowseType.Full;
             break;
     }
     return artistBrowseType;
 }
Ejemplo n.º 2
0
        public ArtistBrowseResult ArtistBrowse(string artistId, ArtistBrowsingType type)
        {
            LoginService.EnsureUserIsLoggedIn();

            using (var link = _session.FromLink<IArtist>(artistId))
            {
                using (link.Object)
                {
                    return _session
                        .BrowseAsync(link.Object, Convertion.ConvertBack(type))
                        .ContinueWith(t => Convertion.ConvertToDto(t.Result))
                        .ContinueWith(t =>
                        {
                            if (t.Exception != null)
                            {
                                _log.Error(t.Exception);
                                return new ArtistBrowseResult();
                            }

                            return t.Result;
                        }).Result;
                }
            }
        }
Ejemplo n.º 3
0
        public IAsyncResult BeginArtistBrowse(string artistId, ArtistBrowsingType type, AsyncCallback callback, object state)
        {
            LoginService.EnsureUserIsLoggedIn();
            var link = _session.FromLink<IArtist>(artistId);

            return _session
                .BrowseAsync(link.Object, Convertion.ConvertBack(type))
                .ContinueWith(t =>
                {
                    using (link)
                    {
                        using (link.Object)
                        {
                            return Convertion.ConvertToDto(t.Result);
                        }
                    }
                })
                .ContinueWith(t => callback(t));
        }