Class IntegerEnumConverter<TEnum>
Newtonsoft: Implements a type converter that converts between integers and an enum type.
Namespace: Neon.Data
Assembly: Neon.Common.dll
Syntax
public class IntegerEnumConverter<TEnum> : JsonConverter where TEnum : struct, EnumType Parameters
| Name | Description | 
|---|---|
| TEnum | The enumation type being converted. | 
Remarks
note
This works for both string and integer values and we don't ensure that an integer input value actually corresponds to an enum value, we just cast the integer.
Methods
CanConvert(Type)
Determines whether the converter is able to convert a value of a specific type.
Declaration
public override bool CanConvert(Type objectType)Parameters
| Type | Name | Description | 
|---|---|---|
| Type | objectType | The value type. | 
Returns
| Type | Description | 
|---|---|
| bool | 
 | 
ReadJson(JsonReader, Type, object, JsonSerializer)
Reads an integer or enum value as a enum.
Declaration
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)Parameters
| Type | Name | Description | 
|---|---|---|
| JsonReader | reader | The reader. | 
| Type | objectType | The value type. | 
| object | existingValue | The existing value. | 
| JsonSerializer | serializer | The serializer. | 
Returns
| Type | Description | 
|---|---|
| object | The value read. | 
Remarks
note
The serializer parameter is ignored.
WriteJson(JsonWriter, object, JsonSerializer)
Writes an integer or enum value as an integer.
Declaration
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)Parameters
| Type | Name | Description | 
|---|---|---|
| JsonWriter | writer | The writer. | 
| object | value | The value. | 
| JsonSerializer | serializer | The serializer. | 
Remarks
note
The serializer parameter is ignored.