Assembly: OptimaJet.Workflow.Core

Class SystemStringEnumConverter<T>

OptimaJet.Workflow.Core.Designer.SystemStringEnumConverter<T>

Converts JSON strings to and from enumeration values of type T. Deserialization parses enumeration names without regard to case, while serialization uses Enum.ToString().

public class SystemStringEnumConverter<T> : JsonConverter<T> where T : struct, Enum

Type Hierarchy

Methods

public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) #
Reads a JSON string and parses it as an enumeration value of type T without regard to case.

Parameters

Name
Type
Description
reader
Utf8JsonReader
The Utf8JsonReader positioned at the value to read.
typeToConvert
Type
The Type being converted.
options
JsonSerializerOptions
The JsonSerializerOptions for the current deserialization operation.

Returns

Type
Description
{T}
The enumeration value parsed from the JSON string.

Exceptions

Type
Description
JsonException
The current token is not JsonTokenType.String, or its value cannot be parsed as T.
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) #
Writes an enumeration value as a JSON string containing the result of Enum.ToString().

Parameters

Name
Type
Description
writer
Utf8JsonWriter
The Utf8JsonWriter to which the value is written.
value
{T}
The enumeration value to write.
options
JsonSerializerOptions
The JsonSerializerOptions for the current serialization operation.