Handle check in if statement

This commit is contained in:
Archangel
2025-02-17 15:14:07 +01:00
parent cfca1e221f
commit b122f7106c
@@ -24,8 +24,11 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
static StringToNumberConverter()
{
// Do reflection only once to get parse
var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);
stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string)]);
if (stringParseMethod == null)
{
var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);
stringParseMethod = underlyingType.GetMethod("Parse", [typeof(string)]);
}
}
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)