<PackageReference Include="System.Text.Json" Version="7.0.4" />

JsonConverterFactory

public abstract class JsonConverterFactory : JsonConverter
Supports converting several types by using a factory pattern.
using System.Runtime.CompilerServices; using System.Text.Json.Serialization.Metadata; namespace System.Text.Json.Serialization { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public abstract class JsonConverterFactory : JsonConverter { internal sealed override ConverterStrategy ConverterStrategy => ConverterStrategy.None; [System.Runtime.CompilerServices.Nullable(2)] internal sealed override Type KeyType { get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] internal sealed override Type ElementType { get { return null; } } internal sealed override Type TypeToConvert => null; [return: System.Runtime.CompilerServices.Nullable(2)] public abstract JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options); internal override JsonParameterInfo CreateJsonParameterInfo() { throw new InvalidOperationException(); } internal JsonConverter GetConverterInternal(Type typeToConvert, JsonSerializerOptions options) { JsonConverter jsonConverter = CreateConverter(typeToConvert, options); if (jsonConverter != null) { if (jsonConverter is JsonConverterFactory) ThrowHelper.ThrowInvalidOperationException_SerializerConverterFactoryReturnsJsonConverterFactorty(GetType()); } else ThrowHelper.ThrowInvalidOperationException_SerializerConverterFactoryReturnsNull(GetType()); return jsonConverter; } internal sealed override object ReadCoreAsObject(ref Utf8JsonReader reader, JsonSerializerOptions options, [System.Runtime.CompilerServices.ScopedRef] ref ReadStack state) { throw new InvalidOperationException(); } internal sealed override bool OnTryReadAsObject(ref Utf8JsonReader reader, JsonSerializerOptions options, [System.Runtime.CompilerServices.ScopedRef] ref ReadStack state, out object value) { throw new InvalidOperationException(); } internal sealed override bool TryReadAsObject(ref Utf8JsonReader reader, JsonSerializerOptions options, [System.Runtime.CompilerServices.ScopedRef] ref ReadStack state, out object value) { throw new InvalidOperationException(); } internal sealed override bool TryWriteAsObject(Utf8JsonWriter writer, object value, JsonSerializerOptions options, ref WriteStack state) { throw new InvalidOperationException(); } internal sealed override bool WriteCoreAsObject(Utf8JsonWriter writer, object value, JsonSerializerOptions options, ref WriteStack state) { throw new InvalidOperationException(); } internal sealed override void WriteAsPropertyNameCoreAsObject(Utf8JsonWriter writer, object value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) { throw new InvalidOperationException(); } internal sealed override JsonConverter<TTarget> CreateCastingConverter<TTarget>() { ThrowHelper.ThrowInvalidOperationException_ConverterCanConvertMultipleTypes(typeof(TTarget), this); return null; } } }