コード例 #1
0
        public override sealed void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
        {
            // Bridge from resumable to value converters.
            if (options == null)
            {
                options = JsonSerializerOptions.s_defaultOptions;
            }

            WriteStack state = default;

            state.Initialize(typeof(T), options, supportContinuation: false);
            TryWrite(writer, value, options, ref state);
        }
コード例 #2
0
        public sealed override void Write(BinaryWriter writer, T value, BinarySerializerOptions options)
        {
            // Bridge from resumable to value converters.
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            WriteStack state     = default;
            Type       inputType = value == null ? typeof(T) : value.GetType();

            state.Initialize(inputType, options, supportContinuation: false);
            TryWrite(writer, value, options, ref state);
        }
コード例 #3
0
        public sealed override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
        {
            // Bridge from resumable to value converters.
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            WriteStack state = default;

            state.Initialize(typeof(T), options, supportContinuation: false);
            try
            {
                TryWrite(writer, value, options, ref state);
            }
            catch
            {
                state.DisposePendingDisposablesOnException();
                throw;
            }
        }