Exemple #1
0
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktMostAnticipatedShow 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_SHOW_PROPERTY_NAME_LIST_COUNT, cancellationToken).ConfigureAwait(false);

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

            if (obj.Show != null)
            {
                var showObjectJsonWriter = new ShowObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_ANTICIPATED_SHOW_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false);

                await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktTrendingShow 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_SHOW_PROPERTY_NAME_WATCHERS, cancellationToken).ConfigureAwait(false);

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

            if (obj.Show != null)
            {
                var showObjectJsonWriter = new ShowObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.TRENDING_SHOW_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false);

                await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktRecentlyUpdatedShow 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_SHOW_PROPERTY_NAME_UPDATED_AT, cancellationToken).ConfigureAwait(false);

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

            if (obj.Show != null)
            {
                var showObjectJsonWriter = new ShowObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.RECENTLY_UPDATED_SHOW_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false);

                await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktMostPWCShow 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_SHOW_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_SHOW_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_SHOW_PROPERTY_NAME_COLLECTED_COUNT, cancellationToken).ConfigureAwait(false);

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

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

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

            if (obj.Show != null)
            {
                var showObjectJsonWriter = new ShowObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.MOST_PWC_SHOW_PROPERTY_NAME_SHOW, cancellationToken).ConfigureAwait(false);

                await showObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Show, cancellationToken).ConfigureAwait(false);
            }

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