Пример #1
0
        public override async Task <ITraktCertifications> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var certificationsArrayReader            = new ArrayJsonReader <ITraktCertification>();
                ITraktCertifications traktCertifications = new TraktCertifications();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_US:
                        traktCertifications.US = await certificationsArrayReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktCertifications);
            }

            return(await Task.FromResult(default(ITraktCertifications)));
        }
Пример #2
0
        public override async Task <ITraktSyncHistoryPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();
                var seasonArrayJsonReader   = new ArrayJsonReader <ITraktSyncHistoryPostShowSeason>();
                ITraktSyncHistoryPostShow syncHistoryPostShow = new TraktSyncHistoryPostShow();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_WATCHED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncHistoryPostShow.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_TITLE:
                        syncHistoryPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_YEAR:
                        syncHistoryPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IDS:
                        syncHistoryPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SEASONS:
                        syncHistoryPostShow.Seasons = await seasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncHistoryPostShow);
            }

            return(await Task.FromResult(default(ITraktSyncHistoryPostShow)));
        }
Пример #3
0
        public override async Task <ITraktPostResponseNotFoundSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonIdsReader = new SeasonIdsObjectJsonReader();
                ITraktPostResponseNotFoundSeason postResponseNotFoundSeason = new TraktPostResponseNotFoundSeason();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_IDS:
                        postResponseNotFoundSeason.Ids = await seasonIdsReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(postResponseNotFoundSeason);
            }

            return(await Task.FromResult(default(ITraktPostResponseNotFoundSeason)));
        }
        public override async Task <ITraktUserCustomListItemsPostMovie> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserCustomListItemsPostMovie)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieIdsObjectJsonReader = new MovieIdsObjectJsonReader();
                ITraktUserCustomListItemsPostMovie customListItemsPostMovie = new TraktUserCustomListItemsPostMovie();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_MOVIE_PROPERTY_NAME_IDS:
                        customListItemsPostMovie.Ids = await movieIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(customListItemsPostMovie);
            }

            return(await Task.FromResult(default(ITraktUserCustomListItemsPostMovie)));
        }
Пример #5
0
        public override async Task <ITraktUserHiddenItemsPostSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserHiddenItemsPostSeason)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonIdsObjectJsonReader = new SeasonIdsObjectJsonReader();
                ITraktUserHiddenItemsPostSeason hiddenItemsPostSeason = new TraktUserHiddenItemsPostSeason();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_HIDDEN_ITEMS_POST_SEASON_PROPERTY_NAME_IDS:
                        hiddenItemsPostSeason.Ids = await seasonIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(hiddenItemsPostSeason);
            }

            return(await Task.FromResult(default(ITraktUserHiddenItemsPostSeason)));
        }
Пример #6
0
        public override async Task <ITraktSyncWatchlistPostEpisode> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncWatchlistPostEpisode)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var episodeIdsObjectJsonReader = new EpisodeIdsObjectJsonReader();
                ITraktSyncWatchlistPostEpisode syncWatchlistPostEpisode = new TraktSyncWatchlistPostEpisode();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_WATCHLIST_POST_EPISODE_PROPERTY_NAME_IDS:
                        syncWatchlistPostEpisode.Ids = await episodeIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncWatchlistPostEpisode);
            }

            return(await Task.FromResult(default(ITraktSyncWatchlistPostEpisode)));
        }
        public override async Task <ITraktMovieIds> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktMovieIds traktMovieIds = new TraktMovieIds();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_TRAKT:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktMovieIds.Trakt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_SLUG:
                        traktMovieIds.Slug = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IMDB:
                        traktMovieIds.Imdb = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_TMDB:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktMovieIds.Tmdb = value.Second;
                        }

                        break;
                    }

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktMovieIds);
            }

            return(await Task.FromResult(default(ITraktMovieIds)));
        }
Пример #8
0
        public override async Task <ITraktNetwork> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktNetwork traktNetwork = new TraktNetwork();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_NAME:
                        traktNetwork.Name = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktNetwork);
            }

            return(await Task.FromResult(default(ITraktNetwork)));
        }
Пример #9
0
        public override async Task <ITraktImage> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktImage)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktImage traktImage = new TraktImage();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.IMAGE_PROPERTY_NAME_FULL:
                        traktImage.Full = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktImage);
            }

            return(await Task.FromResult(default(ITraktImage)));
        }
        public override async Task <ITraktEpisodeScrobblePost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var episodeReader = new EpisodeObjectJsonReader();
                var showReader    = new ShowObjectJsonReader();
                ITraktEpisodeScrobblePost episodeScrobblePost = new TraktEpisodeScrobblePost();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_PROGRESS:
                    {
                        Pair <bool, float> value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            episodeScrobblePost.Progress = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_APP_VERSION:
                        episodeScrobblePost.AppVersion = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_APP_DATE:
                        episodeScrobblePost.AppDate = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        episodeScrobblePost.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EPISODE:
                        episodeScrobblePost.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(episodeScrobblePost);
            }

            return(await Task.FromResult(default(ITraktEpisodeScrobblePost)));
        }
Пример #11
0
        public override async Task <ITraktPostResponseNotFoundMovie> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktPostResponseNotFoundMovie)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieIdsReader = new MovieIdsObjectJsonReader();
                ITraktPostResponseNotFoundMovie postResponseNotFoundMovie = new TraktPostResponseNotFoundMovie();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.POST_RESPONSE_NOT_FOUND_MOVIE_PROPERTY_NAME_IDS:
                        postResponseNotFoundMovie.Ids = await movieIdsReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(postResponseNotFoundMovie);
            }

            return(await Task.FromResult(default(ITraktPostResponseNotFoundMovie)));
        }
        public override async Task <ITraktUserCustomListsReorderPost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken).ConfigureAwait(false) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktUserCustomListsReorderPost customListsReorderPost = new TraktUserCustomListsReorderPost();

                while (await jsonReader.ReadAsync(cancellationToken).ConfigureAwait(false) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_RANK:
                        customListsReorderPost.Rank = await JsonReaderHelper.ReadUnsignedIntegerArrayAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        break;
                    }
                }

                return(customListsReorderPost);
            }

            return(await Task.FromResult(default(ITraktUserCustomListsReorderPost)).ConfigureAwait(false));
        }
Пример #13
0
        public override async Task <ITraktUserImages> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserImages)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var imageReader = new ImageObjectJsonReader();
                ITraktUserImages traktUserImage = new TraktUserImages();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_IMAGES_PROPERTY_NAME_AVATAR:
                        traktUserImage.Avatar = await imageReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktUserImage);
            }

            return(await Task.FromResult(default(ITraktUserImages)));
        }
Пример #14
0
        public override async Task <ITraktUserIds> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserIds)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktUserIds traktUserIds = new TraktUserIds();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_IDS_PROPERTY_NAME_SLUG:
                        traktUserIds.Slug = jsonReader.ReadAsString();
                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktUserIds);
            }

            return(await Task.FromResult(default(ITraktUserIds)));
        }
Пример #15
0
        public override async Task <ITraktWatchedShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktWatchedShow)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showObjectReader       = new ShowObjectJsonReader();
                var showSeasonsArrayReader = new WatchedShowSeasonArrayJsonReader();

                ITraktWatchedShow traktWatchedShow = new TraktWatchedShow();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.WATCHED_SHOW_PROPERTY_NAME_PLAYS:
                        traktWatchedShow.Plays = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.WATCHED_SHOW_PROPERTY_NAME_LAST_WATCHED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktWatchedShow.LastWatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.WATCHED_SHOW_PROPERTY_NAME_SHOW:
                        traktWatchedShow.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.WATCHED_SHOW_PROPERTY_NAME_SEASONS:
                        traktWatchedShow.WatchedSeasons = await showSeasonsArrayReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktWatchedShow);
            }

            return(await Task.FromResult(default(ITraktWatchedShow)));
        }
Пример #16
0
        public override async Task <ITraktSyncRatingsPostMovie> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieIdsObjectJsonReader = new MovieIdsObjectJsonReader();
                ITraktSyncRatingsPostMovie syncRatingsPostMovie = new TraktSyncRatingsPostMovie();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_RATED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncRatingsPostMovie.RatedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_RATING:
                        syncRatingsPostMovie.Rating = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_TITLE:
                        syncRatingsPostMovie.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_YEAR:
                        syncRatingsPostMovie.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IDS:
                        syncRatingsPostMovie.Ids = await movieIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncRatingsPostMovie);
            }

            return(await Task.FromResult(default(ITraktSyncRatingsPostMovie)));
        }
Пример #17
0
        public override async Task <ITraktUserCustomListItemsPostResponseNotFoundGroup> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserCustomListItemsPostResponseNotFoundGroup)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var notFoundMoviesReader   = new PostResponseNotFoundMovieArrayJsonReader();
                var notFoundShowsReader    = new PostResponseNotFoundShowArrayJsonReader();
                var notFoundSeasonsReader  = new PostResponseNotFoundSeasonArrayJsonReader();
                var notFoundEpisodesReader = new PostResponseNotFoundEpisodeArrayJsonReader();
                var notFoundPeopleReader   = new PostResponseNotFoundPersonArrayJsonReader();
                ITraktUserCustomListItemsPostResponseNotFoundGroup customListItemsPostResponseNotFoundGroup = new TraktUserCustomListItemsPostResponseNotFoundGroup();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_MOVIES:
                        customListItemsPostResponseNotFoundGroup.Movies = await notFoundMoviesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SHOWS:
                        customListItemsPostResponseNotFoundGroup.Shows = await notFoundShowsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SEASONS:
                        customListItemsPostResponseNotFoundGroup.Seasons = await notFoundSeasonsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_EPISODES:
                        customListItemsPostResponseNotFoundGroup.Episodes = await notFoundEpisodesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_PEOPLE:
                        customListItemsPostResponseNotFoundGroup.People = await notFoundPeopleReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(customListItemsPostResponseNotFoundGroup);
            }

            return(await Task.FromResult(default(ITraktUserCustomListItemsPostResponseNotFoundGroup)));
        }
Пример #18
0
        public override async Task <ITraktSyncHistoryPostShowSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncHistoryPostShowSeason)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var episodeArrayJsonReader = new SyncHistoryPostShowEpisodeArrayJsonReader();
                ITraktSyncHistoryPostShowSeason syncHistoryPostShowSeason = new TraktSyncHistoryPostShowSeason();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_HISTORY_POST_SHOW_SEASON_PROPERTY_NAME_WATCHED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncHistoryPostShowSeason.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_SEASON_PROPERTY_NAME_NUMBER:
                    {
                        Pair <bool, int> value = await JsonReaderHelper.ReadIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncHistoryPostShowSeason.Number = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_SEASON_PROPERTY_NAME_EPISODES:
                        syncHistoryPostShowSeason.Episodes = await episodeArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncHistoryPostShowSeason);
            }

            return(await Task.FromResult(default(ITraktSyncHistoryPostShowSeason)));
        }
Пример #19
0
        public override async Task <ITraktUserFollowRequest> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserFollowRequest)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var userReader = new UserObjectJsonReader();
                ITraktUserFollowRequest traktUserFollowRequest = new TraktUserFollowRequest();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_FOLLOW_REQUEST_PROPERTY_NAME_ID:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktUserFollowRequest.Id = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.USER_FOLLOW_REQUEST_PROPERTY_NAME_REQUESTED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktUserFollowRequest.RequestedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.USER_FOLLOW_REQUEST_PROPERTY_NAME_USER:
                        traktUserFollowRequest.User = await userReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktUserFollowRequest);
            }

            return(await Task.FromResult(default(ITraktUserFollowRequest)));
        }
Пример #20
0
        public override async Task <ITraktSharing> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSharing)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktSharing traktSharing = new TraktSharing();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SHARING_PROPERTY_NAME_FACEBOOK:
                        traktSharing.Facebook = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_TWITTER:
                        traktSharing.Twitter = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_GOOGLE:
                        traktSharing.Google = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_TUMBLR:
                        traktSharing.Tumblr = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_MEDIUM:
                        traktSharing.Medium = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_SLACK:
                        traktSharing.Slack = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktSharing);
            }

            return(await Task.FromResult(default(ITraktSharing)));
        }
Пример #21
0
        public override async Task <ITraktUserEpisodesStatistics> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserEpisodesStatistics)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktUserEpisodesStatistics userEpisodesStatistics = new TraktUserEpisodesStatistics();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_PLAYS:
                        userEpisodesStatistics.Plays = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_WATCHED:
                        userEpisodesStatistics.Watched = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_MINUTES:
                        userEpisodesStatistics.Minutes = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_COLLECTED:
                        userEpisodesStatistics.Collected = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_RATINGS:
                        userEpisodesStatistics.Ratings = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.USER_EPISODES_STATISTICS_PROPERTY_NAME_COMMENTS:
                        userEpisodesStatistics.Comments = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(userEpisodesStatistics);
            }

            return(await Task.FromResult(default(ITraktUserEpisodesStatistics)));
        }
Пример #22
0
        public override async Task <ITraktRateLimitInfo> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktRateLimitInfo traktRateLimitInfo = new TraktRateLimitInfo();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_NAME:
                        traktRateLimitInfo.Name = await jsonReader.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

                        break;

                    case JsonProperties.PROPERTY_NAME_PERIOD:
                        traktRateLimitInfo.Period = await jsonReader.ReadAsInt32Async(cancellationToken).ConfigureAwait(false);

                        break;

                    case JsonProperties.PROPERTY_NAME_LIMIT:
                        traktRateLimitInfo.Limit = await jsonReader.ReadAsInt32Async(cancellationToken).ConfigureAwait(false);

                        break;

                    case JsonProperties.PROPERTY_NAME_REMAINING:
                        traktRateLimitInfo.Remaining = await jsonReader.ReadAsInt32Async(cancellationToken).ConfigureAwait(false);

                        break;

                    case JsonProperties.PROPERTY_NAME_UNTIL:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        if (value.First)
                        {
                            traktRateLimitInfo.Until = value.Second;
                        }

                        break;
                    }

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken).ConfigureAwait(false);

                        break;
                    }
                }

                return(traktRateLimitInfo);
            }

            return(await Task.FromResult(default(ITraktRateLimitInfo)));
        }
        public override async Task <ITraktSyncHistoryRemovePostResponseNotFoundGroup> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncHistoryRemovePostResponseNotFoundGroup)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var notFoundMoviesReader   = new PostResponseNotFoundMovieArrayJsonReader();
                var notFoundShowsReader    = new PostResponseNotFoundShowArrayJsonReader();
                var notFoundSeasonsReader  = new PostResponseNotFoundSeasonArrayJsonReader();
                var notFoundEpisodesReader = new PostResponseNotFoundEpisodeArrayJsonReader();
                ITraktSyncHistoryRemovePostResponseNotFoundGroup syncHistoryRemovePostResponseNotFoundGroup = new TraktSyncHistoryRemovePostResponseNotFoundGroup();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_MOVIES:
                        syncHistoryRemovePostResponseNotFoundGroup.Movies = await notFoundMoviesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SHOWS:
                        syncHistoryRemovePostResponseNotFoundGroup.Shows = await notFoundShowsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SEASONS:
                        syncHistoryRemovePostResponseNotFoundGroup.Seasons = await notFoundSeasonsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_EPISODES:
                        syncHistoryRemovePostResponseNotFoundGroup.Episodes = await notFoundEpisodesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_HISTORY_REMOVE_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_IDS:
                        syncHistoryRemovePostResponseNotFoundGroup.HistoryIds = await JsonReaderHelper.ReadUnsignedLongArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncHistoryRemovePostResponseNotFoundGroup);
            }

            return(await Task.FromResult(default(ITraktSyncHistoryRemovePostResponseNotFoundGroup)));
        }
Пример #24
0
        public override async Task <ITraktEpisodeCommentPost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktEpisodeCommentPost)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var sharingReader = new SharingObjectJsonReader();
                var episodeReader = new EpisodeObjectJsonReader();
                ITraktEpisodeCommentPost episodeCommentPost = new TraktEpisodeCommentPost();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.COMMENT_POST_PROPERTY_NAME_COMMENT:
                        episodeCommentPost.Comment = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.COMMENT_POST_PROPERTY_NAME_SPOILER:
                    {
                        bool?value = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        if (value.HasValue)
                        {
                            episodeCommentPost.Spoiler = value.Value;
                        }

                        break;
                    }

                    case JsonProperties.COMMENT_POST_PROPERTY_NAME_SHARING:
                        episodeCommentPost.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.EPISODE_COMMENT_POST_PROPERTY_NAME_EPISODE:
                        episodeCommentPost.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(episodeCommentPost);
            }

            return(await Task.FromResult(default(ITraktEpisodeCommentPost)));
        }
        public override async Task <ITraktSyncRatingsPostShowEpisode> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncRatingsPostShowEpisode)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktSyncRatingsPostShowEpisode syncRatingsPostShowEpisode = new TraktSyncRatingsPostShowEpisode();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_RATINGS_POST_SHOW_EPISODE_PROPERTY_NAME_RATED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncRatingsPostShowEpisode.RatedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.SYNC_RATINGS_POST_SHOW_EPISODE_PROPERTY_NAME_RATING:
                        syncRatingsPostShowEpisode.Rating = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.SYNC_RATINGS_POST_SHOW_EPISODE_PROPERTY_NAME_NUMBER:
                    {
                        Pair <bool, int> value = await JsonReaderHelper.ReadIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncRatingsPostShowEpisode.Number = value.Second;
                        }

                        break;
                    }

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(syncRatingsPostShowEpisode);
            }

            return(await Task.FromResult(default(ITraktSyncRatingsPostShowEpisode)));
        }
        public override async Task <ITraktMovieRelease> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktMovieRelease traktMovieRelease = new TraktMovieRelease();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_COUNTRY:
                        traktMovieRelease.CountryCode = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_CERTIFICATION:
                        traktMovieRelease.Certification = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_RELEASE_DATE:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktMovieRelease.ReleaseDate = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_RELEASE_TYPE:
                        traktMovieRelease.ReleaseType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktReleaseType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_NOTE:
                        traktMovieRelease.Note = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktMovieRelease);
            }

            return(await Task.FromResult(default(ITraktMovieRelease)));
        }
Пример #27
0
        public override async Task <ITraktUserLikeItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserLikeItem)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var commentReader = new CommentObjectJsonReader();
                var listReader    = new ListObjectJsonReader();
                ITraktUserLikeItem traktUserLikeItem = new TraktUserLikeItem();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_LIKED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktUserLikeItem.LikedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_TYPE:
                        traktUserLikeItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktUserLikeType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_COMMENT:
                        traktUserLikeItem.Comment = await commentReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_LIKE_ITEM_PROPERTY_NAME_LIST:
                        traktUserLikeItem.List = await listReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktUserLikeItem);
            }

            return(await Task.FromResult(default(ITraktUserLikeItem)));
        }
Пример #28
0
        public override async Task <ITraktMovieScrobblePost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktMovieScrobblePost)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieReader = new MovieObjectJsonReader();
                ITraktMovieScrobblePost movieScrobblePost = new TraktMovieScrobblePost();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.SCROBBLE_POST_PROPERTY_NAME_PROGRESS:
                    {
                        Pair <bool, float> value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            movieScrobblePost.Progress = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.SCROBBLE_POST_PROPERTY_NAME_APP_VERSION:
                        movieScrobblePost.AppVersion = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.SCROBBLE_POST_PROPERTY_NAME_APP_DATE:
                        movieScrobblePost.AppDate = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.MOVIE_SCROBBLE_POST_PROPERTY_NAME_MOVIE:
                        movieScrobblePost.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(movieScrobblePost);
            }

            return(await Task.FromResult(default(ITraktMovieScrobblePost)));
        }
Пример #29
0
        public override async Task <ITraktMetadata> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktMetadata traktMetadata = new TraktMetadata();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_MEDIA_TYPE:
                        traktMetadata.MediaType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_RESOLUTION:
                        traktMetadata.MediaResolution = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaResolution>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_AUDIO:
                        traktMetadata.Audio = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudio>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_AUDIO_CHANNELS:
                        traktMetadata.AudioChannels = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudioChannel>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_HDR:
                        traktMetadata.HDR = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaHDR>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_3D:
                        traktMetadata.ThreeDimensional = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktMetadata);
            }

            return(await Task.FromResult(default(ITraktMetadata)));
        }
Пример #30
0
        public override async Task <ITraktPersonShowCreditsCastItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showObjectReader = new ShowObjectJsonReader();

                ITraktPersonShowCreditsCastItem showCreditsCastItem = new TraktPersonShowCreditsCastItem();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_CHARACTERS:
                        showCreditsCastItem.Characters = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EPISODE_COUNT:
                    {
                        var value = await JsonReaderHelper.ReadIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            showCreditsCastItem.EpisodeCount = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_SERIES_REGULAR:
                        showCreditsCastItem.SeriesRegular = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        showCreditsCastItem.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(showCreditsCastItem);
            }

            return(await Task.FromResult(default(ITraktPersonShowCreditsCastItem)));
        }