public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCastMember obj, CancellationToken cancellationToken = default) { if (jsonWriter == null) { throw new ArgumentNullException(nameof(jsonWriter)); } await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(obj.Character)) { await jsonWriter.WritePropertyNameAsync(JsonProperties.CAST_MEMBER_PROPERTY_NAME_CHARACTER, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Character, cancellationToken).ConfigureAwait(false); } if (obj.Person != null) { var personObjectJsonWriter = new PersonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.CAST_MEMBER_PROPERTY_NAME_PERSON, cancellationToken).ConfigureAwait(false); await personObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Person, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktShowCastMember obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Characters != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_CHARACTERS, cancellationToken).ConfigureAwait(false); await JsonWriterHelper.WriteStringArrayAsync(jsonWriter, obj.Characters, cancellationToken).ConfigureAwait(false); } if (obj.EpisodeCount.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_EPISODE_COUNT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.EpisodeCount.Value, cancellationToken).ConfigureAwait(false); } if (obj.Person != null) { var personObjectJsonWriter = new PersonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_PERSON, cancellationToken).ConfigureAwait(false); await personObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Person, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktCrewMember obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Jobs != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_JOBS, cancellationToken).ConfigureAwait(false); await JsonWriterHelper.WriteStringArrayAsync(jsonWriter, obj.Jobs, cancellationToken).ConfigureAwait(false); } if (obj.Person != null) { var personObjectJsonWriter = new PersonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_PERSON, cancellationToken).ConfigureAwait(false); await personObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Person, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktListItem obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Id.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_ID, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Id, cancellationToken).ConfigureAwait(false); } if (!string.IsNullOrEmpty(obj.Rank)) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_RANK, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Rank, cancellationToken).ConfigureAwait(false); } if (obj.ListedAt.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_LISTED_AT, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.ListedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false); } if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_TYPE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Season != null) { var seasonObjectJsonWriter = new SeasonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SEASON, cancellationToken).ConfigureAwait(false); await seasonObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Season, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } if (obj.Person != null) { var personObjectJsonWriter = new PersonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_PERSON, cancellationToken).ConfigureAwait(false); await personObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Person, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }
public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktSearchResult obj, CancellationToken cancellationToken = default) { CheckJsonTextWriter(jsonWriter); await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false); if (obj.Type != null) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_TYPE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Type.ObjectName, cancellationToken).ConfigureAwait(false); } if (obj.Score.HasValue) { await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SCORE, cancellationToken).ConfigureAwait(false); await jsonWriter.WriteValueAsync(obj.Score, cancellationToken).ConfigureAwait(false); } if (obj.Movie != null) { var movieObjectJsonWriter = new MovieObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false); await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false); } if (obj.Show != null) { var showObjectJsonWriter = new ShowObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false); await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false); } if (obj.Episode != null) { var episodeObjectJsonWriter = new EpisodeObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_EPISODE, cancellationToken).ConfigureAwait(false); await episodeObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Episode, cancellationToken).ConfigureAwait(false); } if (obj.Person != null) { var personObjectJsonWriter = new PersonObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_PERSON, cancellationToken).ConfigureAwait(false); await personObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Person, cancellationToken).ConfigureAwait(false); } if (obj.List != null) { var listObjectJsonWriter = new ListObjectJsonWriter(); await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_LIST, cancellationToken).ConfigureAwait(false); await listObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.List, cancellationToken).ConfigureAwait(false); } await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false); }