Esempio n. 1
0
        private object CreateErrorResponse(Type objectType, Error error)
        {
            if (objectType == typeof(AlbumObjectResponse))
            {
                return(AlbumObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(ArtistObjectResponse))
            {
                return(ArtistObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(PlaylistObjectResponse))
            {
                return(PlaylistObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(RadioObjectResponse))
            {
                return(RadioObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(TrackObjectResponse))
            {
                return(TrackObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(UserObjectResponse))
            {
                return(UserObjectResponse.CreateFrom(null, error));
            }
            else if (objectType == typeof(UserProfileObjectResponse))
            {
                return(UserProfileObjectResponse.CreateFrom(null, error));
            }

            throw new Exception("Attempting to deserialize a response type unknown to E.Deezer.");
        }
Esempio n. 2
0
        private object CreateObjectResponse(Type objectType, JObject valueObject)
        {
            if (objectType == typeof(AlbumObjectResponse))
            {
                var album = valueObject.ToObject <Album>();
                return(AlbumObjectResponse.CreateFrom(album, null));
            }
            else if (objectType == typeof(ArtistObjectResponse))
            {
                var artist = valueObject.ToObject <Artist>();
                return(ArtistObjectResponse.CreateFrom(artist, null));
            }
            else if (objectType == typeof(PlaylistObjectResponse))
            {
                var playlist = valueObject.ToObject <Playlist>();
                return(PlaylistObjectResponse.CreateFrom(playlist, null));
            }
            else if (objectType == typeof(RadioObjectResponse))
            {
                var radio = valueObject.ToObject <Radio>();
                return(RadioObjectResponse.CreateFrom(radio, null));
            }
            else if (objectType == typeof(TrackObjectResponse))
            {
                var track = valueObject.ToObject <Track>();
                return(TrackObjectResponse.CreateFrom(track, null));
            }
            else if (objectType == typeof(UserObjectResponse))
            {
                var user = valueObject.ToObject <User>();
                return(UserObjectResponse.CreateFrom(user, null));
            }
            else if (objectType == typeof(UserProfileObjectResponse))
            {
                var userProfile = valueObject.ToObject <UserProfile>();
                return(UserProfileObjectResponse.CreateFrom(userProfile, null));
            }

            throw new Exception("Attempting to deserialize a response type unknown to E.Deezer.");
        }