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

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var groupReader         = new SyncPostResponseGroupObjectJsonReader();
                var notFoundGroupReader = new SyncRatingsPostResponseNotFoundGroupObjectJsonReader();
                ITraktSyncRatingsPostResponse syncRatingsPostResponse = new TraktSyncRatingsPostResponse();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_RATINGS_POST_RESPONSE_PROPERTY_NAME_ADDED:
                        syncRatingsPostResponse.Added = await groupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_RATINGS_POST_RESPONSE_PROPERTY_NAME_NOT_FOUND:
                        syncRatingsPostResponse.NotFound = await notFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(syncRatingsPostResponse);
            }

            return(await Task.FromResult(default(ITraktSyncRatingsPostResponse)));
        }
Exemple #2
0
        public override async Task <IEnumerable <ITraktSyncRatingsPostResponseNotFoundGroup> > ReadArrayAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(IEnumerable <ITraktSyncRatingsPostResponseNotFoundGroup>)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartArray)
            {
                var syncRatingsPostResponseNotFoundGroupReader = new SyncRatingsPostResponseNotFoundGroupObjectJsonReader();
                var syncRatingsPostResponseNotFoundGroups      = new List <ITraktSyncRatingsPostResponseNotFoundGroup>();
                ITraktSyncRatingsPostResponseNotFoundGroup syncRatingsPostResponseNotFoundGroup = await syncRatingsPostResponseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                while (syncRatingsPostResponseNotFoundGroup != null)
                {
                    syncRatingsPostResponseNotFoundGroups.Add(syncRatingsPostResponseNotFoundGroup);
                    syncRatingsPostResponseNotFoundGroup = await syncRatingsPostResponseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);
                }

                return(syncRatingsPostResponseNotFoundGroups);
            }

            return(await Task.FromResult(default(IEnumerable <ITraktSyncRatingsPostResponseNotFoundGroup>)));
        }