public sealed override T?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (options is null) { ThrowHelper.ThrowArgumentNullException(nameof(options)); } // Bridge from resumable to value converters. ReadStack state = default; JsonTypeInfo jsonTypeInfo = options.GetTypeInfoInternal(typeToConvert); state.Initialize(jsonTypeInfo); TryRead(ref reader, typeToConvert, options, ref state, out T? value); return(value); }
public sealed override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { if (options is null) { ThrowHelper.ThrowArgumentNullException(nameof(options)); } // Bridge from resumable to value converters. WriteStack state = default; JsonTypeInfo typeInfo = options.GetTypeInfoInternal(typeof(T)); state.Initialize(typeInfo); try { TryWrite(writer, value, options, ref state); } catch { state.DisposePendingDisposablesOnException(); throw; } }