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

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var responseGroupReader         = new UserCustomListItemsPostResponseGroupObjectJsonReader();
                var responseNotFoundGroupReader = new UserCustomListItemsPostResponseNotFoundGroupObjectJsonReader();
                ITraktUserCustomListItemsPostResponse customListItemsPostResponse = new TraktUserCustomListItemsPostResponse();

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

                    switch (propertyName)
                    {
                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_PROPERTY_NAME_ADDED:
                        customListItemsPostResponse.Added = await responseGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_PROPERTY_NAME_EXISTING:
                        customListItemsPostResponse.Existing = await responseGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_PROPERTY_NAME_NOT_FOUND:
                        customListItemsPostResponse.NotFound = await responseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(customListItemsPostResponse);
            }

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

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var responseGroupReader         = new UserCustomListItemsPostResponseGroupObjectJsonReader();
                var responseNotFoundGroupReader = new UserCustomListItemsPostResponseNotFoundGroupObjectJsonReader();
                ITraktUserCustomListItemsRemovePostResponse customListItemsRemovePostResponse = new TraktUserCustomListItemsRemovePostResponse();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_DELETED:
                        customListItemsRemovePostResponse.Deleted = await responseGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_NOT_FOUND:
                        customListItemsRemovePostResponse.NotFound = await responseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(customListItemsRemovePostResponse);
            }

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

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartArray)
            {
                var userCustomListItemsPostResponseNotFoundGroupReader = new UserCustomListItemsPostResponseNotFoundGroupObjectJsonReader();
                var userCustomListItemsPostResponseNotFoundGroups      = new List <ITraktUserCustomListItemsPostResponseNotFoundGroup>();
                ITraktUserCustomListItemsPostResponseNotFoundGroup userCustomListItemsPostResponseNotFoundGroup = await userCustomListItemsPostResponseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);

                while (userCustomListItemsPostResponseNotFoundGroup != null)
                {
                    userCustomListItemsPostResponseNotFoundGroups.Add(userCustomListItemsPostResponseNotFoundGroup);
                    userCustomListItemsPostResponseNotFoundGroup = await userCustomListItemsPostResponseNotFoundGroupReader.ReadObjectAsync(jsonReader, cancellationToken);
                }

                return(userCustomListItemsPostResponseNotFoundGroups);
            }

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