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