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))); }
public override async Task <ITraktShowCrewMember> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var personReader = new PersonObjectJsonReader(); ITraktShowCrewMember traktShowCrewMember = new TraktShowCrewMember(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_JOBS: traktShowCrewMember.Jobs = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_EPISODE_COUNT: { var value = await JsonReaderHelper.ReadIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowCrewMember.EpisodeCount = value.Second; } break; } case JsonProperties.PROPERTY_NAME_PERSON: traktShowCrewMember.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktShowCrewMember); } return(await Task.FromResult(default(ITraktShowCrewMember))); }
public override async Task <ITraktPersonMovieCreditsCrewItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var movieObjectReader = new MovieObjectJsonReader(); ITraktPersonMovieCreditsCrewItem movieCreditsCrewItem = new TraktPersonMovieCreditsCrewItem(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_JOBS: movieCreditsCrewItem.Jobs = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_MOVIE: movieCreditsCrewItem.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(movieCreditsCrewItem); } return(await Task.FromResult(default(ITraktPersonMovieCreditsCrewItem))); }
public override async Task <ITraktCastMember> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var personReader = new PersonObjectJsonReader(); ITraktCastMember traktCastMember = new TraktCastMember(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_CHARACTERS: traktCastMember.Characters = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.PROPERTY_NAME_PERSON: traktCastMember.Person = await personReader.ReadObjectAsync(jsonReader, cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktCastMember); } return(await Task.FromResult(default(ITraktCastMember))); }
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 <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 <ITraktEpisode> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { if (jsonReader == null) { return(await Task.FromResult(default(ITraktEpisode))); } if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { var idsObjectReader = new EpisodeIdsObjectJsonReader(); var translationArrayReader = new EpisodeTranslationArrayJsonReader(); ITraktEpisode traktEpisode = new TraktEpisode(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.EPISODE_PROPERTY_NAME_SEASON_NUMBER: traktEpisode.SeasonNumber = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_NUMBER: traktEpisode.Number = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_TITLE: traktEpisode.Title = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_IDS: traktEpisode.Ids = await idsObjectReader.ReadObjectAsync(jsonReader, cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_NUMBER_ABSOLUTE: traktEpisode.NumberAbsolute = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_OVERVIEW: traktEpisode.Overview = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_RUNTIME: traktEpisode.Runtime = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_RATING: traktEpisode.Rating = (float?)await jsonReader.ReadAsDoubleAsync(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_VOTES: traktEpisode.Votes = await jsonReader.ReadAsInt32Async(cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_FIRST_AIRED: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktEpisode.FirstAired = value.Second; } break; } case JsonProperties.EPISODE_PROPERTY_NAME_UPDATED_AT: { var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken); if (value.First) { traktEpisode.UpdatedAt = value.Second; } break; } case JsonProperties.EPISODE_PROPERTY_NAME_AVAILABLE_TRANSLATIONS: traktEpisode.AvailableTranslationLanguageCodes = await JsonReaderHelper.ReadStringArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_TRANSLATIONS: traktEpisode.Translations = await translationArrayReader.ReadArrayAsync(jsonReader, cancellationToken); break; case JsonProperties.EPISODE_PROPERTY_NAME_COMMENT_COUNT: traktEpisode.CommentCount = await jsonReader.ReadAsInt32Async(cancellationToken); break; default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktEpisode); } return(await Task.FromResult(default(ITraktEpisode))); }