public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) { Debug.Assert(typeToConvert.GetGenericArguments().Length > 0); Type valueTypeToConvert = typeToConvert.GetGenericArguments()[0]; JsonConverter valueConverter = options.GetConverter(valueTypeToConvert); Debug.Assert(valueConverter != null); return(CreateValueConverter(valueTypeToConvert, valueConverter)); }
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) { Debug.Assert(typeToConvert.GetGenericArguments().Length > 0); Type valueTypeToConvert = typeToConvert.GetGenericArguments()[0]; JsonConverter?valueConverter = options.GetConverter(valueTypeToConvert); if (valueConverter == null) { ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(valueTypeToConvert); } return(CreateValueConverter(valueTypeToConvert, valueConverter)); }
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) { Debug.Assert(typeToConvert.GetGenericArguments().Length > 0); Type valueTypeToConvert = typeToConvert.GetGenericArguments()[0]; JsonConverter?valueConverter = options.GetConverter(valueTypeToConvert); if (valueConverter == null) { ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(valueTypeToConvert); } JsonConverter converter = (JsonConverter)Activator.CreateInstance( typeof(JsonValueConverterNullable <>).MakeGenericType(valueTypeToConvert), BindingFlags.Instance | BindingFlags.Public, binder: null, args: new object[] { valueConverter }, culture: null) !; return(converter); }