public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktUserFollowRequest obj, CancellationToken cancellationToken = default)
        {
            CheckJsonTextWriter(jsonWriter);
            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_ID, cancellationToken).ConfigureAwait(false);

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

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

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

            if (obj.User != null)
            {
                var userObjectJsonWriter = new UserObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_USER, cancellationToken).ConfigureAwait(false);

                await userObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.User, cancellationToken).ConfigureAwait(false);
            }

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

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

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

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

            if (obj.User != null)
            {
                var userObjectJsonWriter = new UserObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_FOLLOWER_PROPERTY_NAME_USER, cancellationToken).ConfigureAwait(false);

                await userObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.User, cancellationToken).ConfigureAwait(false);
            }

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

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

            if (obj.User != null)
            {
                var userObjectJsonWriter = new UserObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_SETTINGS_PROPERTY_NAME_USER, cancellationToken).ConfigureAwait(false);

                await userObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.User, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Account != null)
            {
                var accountSettingsObjectJsonWriter = new AccountSettingsObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_SETTINGS_PROPERTY_NAME_ACCOUNT, cancellationToken).ConfigureAwait(false);

                await accountSettingsObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Account, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Connections != null)
            {
                var sharingObjectJsonWriter = new SharingObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_SETTINGS_PROPERTY_NAME_CONNECTIONS, cancellationToken).ConfigureAwait(false);

                await sharingObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Connections, cancellationToken).ConfigureAwait(false);
            }

            if (obj.SharingText != null)
            {
                var sharingTextObjectJsonWriter = new SharingTextObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_SETTINGS_PROPERTY_NAME_SHARING_TEXT, cancellationToken).ConfigureAwait(false);

                await sharingTextObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.SharingText, cancellationToken).ConfigureAwait(false);
            }

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