示例#1
0
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktBoxOfficeMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Revenue.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.BOX_OFFICE_MOVIE_PROPERTY_NAME_REVENUE, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.Revenue, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.BOX_OFFICE_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktMostAnticipatedMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.ListCount.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_ANTICIPATED_MOVIE_PROPERTY_NAME_LIST_COUNT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.ListCount, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_ANTICIPATED_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktRecentlyUpdatedMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.RecentlyUpdatedAt.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.RECENTLY_UPDATED_MOVIE_PROPERTY_NAME_UPDATED_AT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.RecentlyUpdatedAt.Value.ToTraktLongDateTimeString(), cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.RECENTLY_UPDATED_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktTrendingMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Watchers.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.TRENDING_MOVIE_PROPERTY_NAME_WATCHERS, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.Watchers, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.TRENDING_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
示例#5
0
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktMostPWCMovie obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.WatcherCount.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_PWC_MOVIE_PROPERTY_NAME_WATCHER_COUNT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.WatcherCount, cancellationToken).ConfigureAwait(false);
            }

            if (obj.PlayCount.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_PWC_MOVIE_PROPERTY_NAME_PLAY_COUNT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.PlayCount, cancellationToken).ConfigureAwait(false);
            }

            if (obj.CollectedCount.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_PWC_MOVIE_PROPERTY_NAME_COLLECTED_COUNT, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.CollectedCount, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Movie != null)
            {
                var movieObjectJsonWriter = new MovieObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_PWC_MOVIE_PROPERTY_NAME_MOVIE, cancellationToken).ConfigureAwait(false);

                await movieObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Movie, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }