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))); }
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))); }
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))); }
public override async Task <ITraktAccountSettings> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktAccountSettings traktAccountSettings = new TraktAccountSettings(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TIMEZONE: traktAccountSettings.TimeZoneId = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TIME_24HR: traktAccountSettings.Time24Hr = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_COVER_IMAGE: traktAccountSettings.CoverImage = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TOKEN: traktAccountSettings.Token = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_DATE_FORMAT: traktAccountSettings.DateFormat = await JsonReaderHelper.ReadEnumerationValueAsync <TraktDateFormat>(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktAccountSettings); } return(await Task.FromResult(default(ITraktAccountSettings))); }
public override async Task <ITraktEpisodeScrobblePostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var sharingReader = new SharingObjectJsonReader(); var episodeReader = new EpisodeObjectJsonReader(); var showReader = new ShowObjectJsonReader(); ITraktEpisodeScrobblePostResponse episodeScrobbleResponse = new TraktEpisodeScrobblePostResponse(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_ID: { var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken); if (value.First) { episodeScrobbleResponse.Id = value.Second; } break; } case JsonProperties.PROPERTY_NAME_ACTION: episodeScrobbleResponse.Action = await JsonReaderHelper.ReadEnumerationValueAsync <TraktScrobbleActionType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PROGRESS: { var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken); if (value.First) { episodeScrobbleResponse.Progress = value.Second; } break; } case JsonProperties.PROPERTY_NAME_SHARING: episodeScrobbleResponse.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: episodeScrobbleResponse.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: episodeScrobbleResponse.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(episodeScrobbleResponse); } return(await Task.FromResult(default(ITraktEpisodeScrobblePostResponse))); }
public override async Task <ITraktShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktShow))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var idsObjectReader = new ShowIdsObjectJsonReader(); var airsObjectReader = new ShowAirsObjectJsonReader(); var seasonsArrayReader = new SeasonArrayJsonReader(); ITraktShow traktShow = new TraktShow(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.SHOW_PROPERTY_NAME_TITLE: traktShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_YEAR: traktShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_IDS: traktShow.Ids = await idsObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_OVERVIEW: traktShow.Overview = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_FIRST_AIRED: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktShow.FirstAired = value.Second; } break; } case JsonProperties.SHOW_PROPERTY_NAME_AIRS: traktShow.Airs = await airsObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_RUNTIME: traktShow.Runtime = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_CERTIFICATION: traktShow.Certification = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_NETWORK: traktShow.Network = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_COUNTRY: traktShow.CountryCode = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_TRAILER: traktShow.Trailer = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_HOMEPAGE: traktShow.Homepage = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_STATUS: traktShow.Status = await JsonReaderHelper.ReadEnumerationValueAsync <TraktShowStatus>(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_RATING: traktShow.Rating = (float?)await jsonReader.ReadAsDoubleAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_VOTES: traktShow.Votes = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_UPDATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktShow.UpdatedAt = value.Second; } break; } case JsonProperties.SHOW_PROPERTY_NAME_LANGUAGE: traktShow.LanguageCode = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_AVAILABLE_TRANSLATIONS: traktShow.AvailableTranslationLanguageCodes = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_GENRES: traktShow.Genres = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_AIRED_EPISODES: traktShow.AiredEpisodes = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_SEASONS: traktShow.Seasons = await seasonsArrayReader.ReadArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.SHOW_PROPERTY_NAME_COMMENT_COUNT: traktShow.CommentCount = await jsonReader.ReadAsInt32Async(cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktShow); } return(await Task.FromResult(default(ITraktShow))); }
public override async Task <ITraktCommentItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktCommentItem traktCommentItem = new TraktCommentItem(); var movieObjectJsonReader = new MovieObjectJsonReader(); var showObjectJsonReader = new ShowObjectJsonReader(); var seasonObjectJsonReader = new SeasonObjectJsonReader(); var episodeObjectJsonReader = new EpisodeObjectJsonReader(); var listObjectJsonReader = new ListObjectJsonReader(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TYPE: traktCommentItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktObjectType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktCommentItem.Movie = await movieObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_SHOW: traktCommentItem.Show = await showObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_SEASON: traktCommentItem.Season = await seasonObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktCommentItem.Episode = await episodeObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_LIST: traktCommentItem.List = await listObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktCommentItem); } return(await Task.FromResult(default(ITraktCommentItem))); }
public override async Task <ITraktUserComment> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserComment))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var commentReader = new CommentObjectJsonReader(); var movieReader = new MovieObjectJsonReader(); var showReader = new ShowObjectJsonReader(); var seasonReader = new SeasonObjectJsonReader(); var episodeReader = new EpisodeObjectJsonReader(); var listReader = new ListObjectJsonReader(); ITraktUserComment traktUserComment = new TraktUserComment(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_COMMENT_PROPERTY_NAME_TYPE: traktUserComment.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktObjectType>(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_COMMENT: traktUserComment.Comment = await commentReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_MOVIE: traktUserComment.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_SHOW: traktUserComment.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_SEASON: traktUserComment.Season = await seasonReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_EPISODE: traktUserComment.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_COMMENT_PROPERTY_NAME_LIST: traktUserComment.List = await listReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserComment); } return(await Task.FromResult(default(ITraktUserComment))); }
public override async Task <ITraktSearchResult> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); var showObjectReader = new ShowObjectJsonReader(); var episodeObjectReader = new EpisodeObjectJsonReader(); var personObjectReader = new PersonObjectJsonReader(); var listObjectReader = new ListObjectJsonReader(); ITraktSearchResult traktSearchResult = new TraktSearchResult(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TYPE: traktSearchResult.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktSearchResultType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SCORE: { var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken); if (value.First) { traktSearchResult.Score = value.Second; } break; } case JsonProperties.PROPERTY_NAME_MOVIE: traktSearchResult.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktSearchResult.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktSearchResult.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PERSON: traktSearchResult.Person = await personObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_LIST: traktSearchResult.List = await listObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktSearchResult); } return(await Task.FromResult(default(ITraktSearchResult))); }
public override async Task <ITraktList> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var idsReader = new ListIdsObjectJsonReader(); var userReader = new UserObjectJsonReader(); ITraktList traktList = new TraktList(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_NAME: traktList.Name = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_DESCRIPTION: traktList.Description = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_PRIVACY: traktList.Privacy = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessScope>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_DISPLAY_NUMBERS: traktList.DisplayNumbers = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_ALLOW_COMMENTS: traktList.AllowComments = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_SORT_BY: traktList.SortBy = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_SORT_HOW: traktList.SortHow = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_CREATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktList.CreatedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_UPDATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktList.UpdatedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_ITEM_COUNT: traktList.ItemCount = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_COMMENT_COUNT: traktList.CommentCount = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_LIKES: traktList.Likes = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_IDS: traktList.Ids = await idsReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_USER: traktList.User = await userReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktList); } return(await Task.FromResult(default(ITraktList))); }
public override async Task <ITraktSyncCollectionPostEpisode> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktSyncCollectionPostEpisode traktSyncCollectionPostEpisode = new TraktSyncCollectionPostEpisode(); var episodeIdsObjectJsonReader = new EpisodeIdsObjectJsonReader(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_COLLECTED_AT: { Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktSyncCollectionPostEpisode.CollectedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_IDS: traktSyncCollectionPostEpisode.Ids = await episodeIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MEDIA_TYPE: traktSyncCollectionPostEpisode.MediaType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_RESOLUTION: traktSyncCollectionPostEpisode.MediaResolution = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaResolution>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_AUDIO: traktSyncCollectionPostEpisode.Audio = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudio>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_AUDIO_CHANNELS: traktSyncCollectionPostEpisode.AudioChannels = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudioChannel>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_3D: traktSyncCollectionPostEpisode.ThreeDimensional = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktSyncCollectionPostEpisode); } return(await Task.FromResult(default(ITraktSyncCollectionPostEpisode))); }
public override async Task <ITraktAuthorization> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktAuthorization))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktAuthorization traktAuthorization = new TraktAuthorization(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_ACCESS_TOKEN: traktAuthorization.AccessToken = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_REFRESH_TOKEN: traktAuthorization.RefreshToken = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_SCOPE: traktAuthorization.Scope = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessScope>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EXPIRES_IN: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktAuthorization.ExpiresInSeconds = value.Second; } break; } case JsonProperties.PROPERTY_NAME_TOKEN_TYPE: traktAuthorization.TokenType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessTokenType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_CREATED_AT: { var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken); if (value.First) { traktAuthorization.CreatedAtTimestamp = value.Second; } break; } case JsonProperties.PROPERTY_NAME_IGNORE_EXPIRATION: if (CompleteDeserialization) { bool?ignoreExpiration = await jsonReader.ReadAsBooleanAsync(cancellationToken); traktAuthorization.IgnoreExpiration = ignoreExpiration ?? false; } break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktAuthorization); } return(await Task.FromResult(default(ITraktAuthorization))); }
public override async Task <ITraktUserWatchingItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserWatchingItem))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieReader = new MovieObjectJsonReader(); var showReader = new ShowObjectJsonReader(); var episodeReader = new EpisodeObjectJsonReader(); ITraktUserWatchingItem traktUserWatchingItem = new TraktUserWatchingItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_STARTED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktUserWatchingItem.StartedAt = value.Second; } break; } case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_EXPIRES_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktUserWatchingItem.ExpiresAt = value.Second; } break; } case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_ACTION: traktUserWatchingItem.Action = await JsonReaderHelper.ReadEnumerationValueAsync <TraktHistoryActionType>(jsonReader, cancellationToken); break; case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_TYPE: traktUserWatchingItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktSyncType>(jsonReader, cancellationToken); break; case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_MOVIE: traktUserWatchingItem.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_SHOW: traktUserWatchingItem.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_WATCHING_ITEM_PROPERTY_NAME_EPISODE: traktUserWatchingItem.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserWatchingItem); } return(await Task.FromResult(default(ITraktUserWatchingItem))); }
public override async Task <ITraktSyncCollectionPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktSyncCollectionPostShow))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktSyncCollectionPostShow traktSyncCollectionPostShow = new TraktSyncCollectionPostShow(); var showIdsObjectJsonReader = new ShowIdsObjectJsonReader(); var syncCollectionPostShowSeasonArrayJsonReader = new SyncCollectionPostShowSeasonArrayReader(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.SYNC_COLLECTION_POST_SHOW_PROPERTY_NAME_COLLECTED_AT: { Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktSyncCollectionPostShow.CollectedAt = value.Second; } break; } case JsonProperties.SYNC_COLLECTION_POST_SHOW_PROPERTY_NAME_TITLE: traktSyncCollectionPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.SYNC_COLLECTION_POST_SHOW_PROPERTY_NAME_YEAR: traktSyncCollectionPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.SYNC_COLLECTION_POST_SHOW_PROPERTY_NAME_IDS: traktSyncCollectionPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.SYNC_COLLECTION_POST_SHOW_PROPERTY_NAME_SEASONS: traktSyncCollectionPostShow.Seasons = await syncCollectionPostShowSeasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.METADATA_PROPERTY_NAME_MEDIA_TYPE: traktSyncCollectionPostShow.MediaType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaType>(jsonReader, cancellationToken); break; case JsonProperties.METADATA_PROPERTY_NAME_RESOLUTION: traktSyncCollectionPostShow.MediaResolution = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaResolution>(jsonReader, cancellationToken); break; case JsonProperties.METADATA_PROPERTY_NAME_AUDIO: traktSyncCollectionPostShow.Audio = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudio>(jsonReader, cancellationToken); break; case JsonProperties.METADATA_PROPERTY_NAME_AUDIO_CHANNELS: traktSyncCollectionPostShow.AudioChannels = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudioChannel>(jsonReader, cancellationToken); break; case JsonProperties.METADATA_PROPERTY_NAME_3D: traktSyncCollectionPostShow.ThreeDimensional = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktSyncCollectionPostShow); } return(await Task.FromResult(default(ITraktSyncCollectionPostShow))); }
public override async Task <ITraktRatingsItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); var showObjectReader = new ShowObjectJsonReader(); var seasonObjectReader = new SeasonObjectJsonReader(); var episodeObjectReader = new EpisodeObjectJsonReader(); ITraktRatingsItem traktRatingItem = new TraktRatingsItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_RATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktRatingItem.RatedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_RATING: traktRatingItem.Rating = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TYPE: traktRatingItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktRatingsItemType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktRatingItem.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktRatingItem.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SEASON: traktRatingItem.Season = await seasonObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktRatingItem.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktRatingItem); } return(await Task.FromResult(default(ITraktRatingsItem))); }
public override async Task <ITraktSyncPlaybackProgressItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); var showObjectReader = new ShowObjectJsonReader(); var episodeObjectReader = new EpisodeObjectJsonReader(); ITraktSyncPlaybackProgressItem traktPlaybackProgressItem = new TraktSyncPlaybackProgressItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_ID: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktPlaybackProgressItem.Id = value.Second; } break; } case JsonProperties.PROPERTY_NAME_PROGRESS: { var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken); if (value.First) { traktPlaybackProgressItem.Progress = value.Second; } break; } case JsonProperties.PROPERTY_NAME_PAUSED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktPlaybackProgressItem.PausedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_TYPE: traktPlaybackProgressItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktSyncType>(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktPlaybackProgressItem.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_SHOW: traktPlaybackProgressItem.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE: traktPlaybackProgressItem.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktPlaybackProgressItem); } return(await Task.FromResult(default(ITraktSyncPlaybackProgressItem))); }
public override async Task <ITraktUserCustomListPost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserCustomListPost))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktUserCustomListPost userCustomListPost = new TraktUserCustomListPost(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_NAME: userCustomListPost.Name = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_DESCRIPTION: userCustomListPost.Description = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_PRIVACY: userCustomListPost.Privacy = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessScope>(jsonReader, cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_DISPLAY_NUMBERS: userCustomListPost.DisplayNumbers = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_ALLOW_COMMENTS: userCustomListPost.AllowComments = await jsonReader.ReadAsBooleanAsync(cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_SORT_BY: userCustomListPost.SortBy = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.USER_CUSTOM_LIST_POST_PROPERTY_NAME_SORT_HOW: userCustomListPost.SortHow = await jsonReader.ReadAsStringAsync(cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(userCustomListPost); } return(await Task.FromResult(default(ITraktUserCustomListPost))); }
public override async Task <ITraktMovie> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var idsObjectReader = new MovieIdsObjectJsonReader(); ITraktMovie traktMovie = new TraktMovie(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TITLE: traktMovie.Title = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_YEAR: traktMovie.Year = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_IDS: traktMovie.Ids = await idsObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_TAGLINE: traktMovie.Tagline = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_OVERVIEW: traktMovie.Overview = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_RELEASED: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktMovie.Released = value.Second; } break; } case JsonProperties.PROPERTY_NAME_RUNTIME: traktMovie.Runtime = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TRAILER: traktMovie.Trailer = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_HOMEPAGE: traktMovie.Homepage = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_RATING: traktMovie.Rating = (float?)await jsonReader.ReadAsDoubleAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_VOTES: traktMovie.Votes = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_UPDATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktMovie.UpdatedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_LANGUAGE: traktMovie.LanguageCode = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_AVAILABLE_TRANSLATIONS: traktMovie.AvailableTranslationLanguageCodes = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_GENRES: traktMovie.Genres = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_CERTIFICATION: traktMovie.Certification = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_COUNTRY: traktMovie.CountryCode = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_COMMENT_COUNT: traktMovie.CommentCount = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.PROPERTY_NAME_STATUS: traktMovie.Status = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMovieStatus>(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktMovie); } return(await Task.FromResult(default(ITraktMovie))); }
public override async Task <ITraktMovieScrobblePostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktMovieScrobblePostResponse))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var sharingReader = new SharingObjectJsonReader(); var movieReader = new MovieObjectJsonReader(); ITraktMovieScrobblePostResponse movieScrobbleResponse = new TraktMovieScrobblePostResponse(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.SCROBBLE_POST_RESPONSE_PROPERTY_NAME_ID: { var value = await JsonReaderHelper.ReadUnsignedLongIntegerAsync(jsonReader, cancellationToken); if (value.First) { movieScrobbleResponse.Id = value.Second; } break; } case JsonProperties.SCROBBLE_POST_RESPONSE_PROPERTY_NAME_ACTION: movieScrobbleResponse.Action = await JsonReaderHelper.ReadEnumerationValueAsync <TraktScrobbleActionType>(jsonReader, cancellationToken); break; case JsonProperties.SCROBBLE_POST_RESPONSE_PROPERTY_NAME_PROGRESS: { var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken); if (value.First) { movieScrobbleResponse.Progress = value.Second; } break; } case JsonProperties.SCROBBLE_POST_RESPONSE_PROPERTY_NAME_SHARING: movieScrobbleResponse.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.MOVIE_SCROBBLE_POST_RESPONSE_PROPERTY_NAME_MOVIE: movieScrobbleResponse.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(movieScrobbleResponse); } return(await Task.FromResult(default(ITraktMovieScrobblePostResponse))); }
public override async Task <ITraktRecommendation> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); var showObjectReader = new ShowObjectJsonReader(); ITraktRecommendation traktRecommendation = new TraktRecommendation(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_RANK: traktRecommendation.Rank = await jsonReader.ReadAsInt32Async(cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_LISTED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken).ConfigureAwait(false); if (value.First) { traktRecommendation.ListedAt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_TYPE: traktRecommendation.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktRecommendationObjectType>(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_NOTES: traktRecommendation.Notes = await jsonReader.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_MOVIE: traktRecommendation.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; case JsonProperties.PROPERTY_NAME_SHOW: traktRecommendation.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken).ConfigureAwait(false); break; } } return(traktRecommendation); } return(await Task.FromResult(default(ITraktRecommendation))); }
public override async Task <ITraktUserHiddenItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktUserHiddenItem))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieReader = new MovieObjectJsonReader(); var showReader = new ShowObjectJsonReader(); var seasonReader = new SeasonObjectJsonReader(); ITraktUserHiddenItem traktUserHiddenItem = new TraktUserHiddenItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.USER_HIDDEN_ITEM_PROPERTY_NAME_HIDDEN_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktUserHiddenItem.HiddenAt = value.Second; } break; } case JsonProperties.USER_HIDDEN_ITEM_PROPERTY_NAME_TYPE: traktUserHiddenItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktHiddenItemType>(jsonReader, cancellationToken); break; case JsonProperties.USER_HIDDEN_ITEM_PROPERTY_NAME_MOVIE: traktUserHiddenItem.Movie = await movieReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_HIDDEN_ITEM_PROPERTY_NAME_SHOW: traktUserHiddenItem.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.USER_HIDDEN_ITEM_PROPERTY_NAME_SEASON: traktUserHiddenItem.Season = await seasonReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktUserHiddenItem); } return(await Task.FromResult(default(ITraktUserHiddenItem))); }