|
|
@ -11,6 +11,8 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T> |
|
|
|
|
|
|
|
|
private JsonSerializerOptions? _readJsonSerializerOptions; |
|
|
private JsonSerializerOptions? _readJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
private JsonSerializerOptions? _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
|
public AbpStringToEnumConverter() |
|
|
public AbpStringToEnumConverter() |
|
|
: this(namingPolicy: null, allowIntegerValues: true) |
|
|
: this(namingPolicy: null, allowIntegerValues: true) |
|
|
{ |
|
|
{ |
|
|
@ -39,7 +41,11 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T> |
|
|
|
|
|
|
|
|
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) |
|
|
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) |
|
|
{ |
|
|
{ |
|
|
JsonSerializer.Serialize(writer, value); |
|
|
_writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(options, x => |
|
|
|
|
|
x == this || |
|
|
|
|
|
x.GetType() == typeof(AbpStringToEnumFactory)); |
|
|
|
|
|
|
|
|
|
|
|
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|