Class CasedStringEnumConverter

Abstract class for cased converter for enum values that should be converted to strings. Enum value is converted to string using implemtation in FormatValueString.

Namespace: EPiServer.Framework.Serialization.Json
Assembly: EPiServer.Framework.dll
Version: 8.11.0
Syntax
public abstract class CasedStringEnumConverter : JsonConverter

Constructors

CasedStringEnumConverter()

Declaration
protected CasedStringEnumConverter()

Methods

CanConvert(Type)

Determines whether this instance can convert the specified object type.

Declaration
public override bool CanConvert(Type objectType)
Parameters
Type Name Description
System.Type objectType

Type of the object.

Returns
Type Description
System.Boolean

true if objectType is an enum

FormatValueString(String)

Format string to correct case

Declaration
protected abstract string FormatValueString(string value)
Parameters
Type Name Description
System.String value

The value

Returns
Type Description
System.String

The value formatted

ReadJson(JsonReader, Type, Object, JsonSerializer)

Reads the JSON representation of the object.

Declaration
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parameters
Type Name Description
Newtonsoft.Json.JsonReader reader

The Newtonsoft.Json.JsonReader to read from.

System.Type objectType

Type of the object.

System.Object existingValue

The existing value of object being read.

Newtonsoft.Json.JsonSerializer serializer

The calling serializer.

Returns
Type Description
System.Object

The object value.

WriteJson(JsonWriter, Object, JsonSerializer)

Writes value (enum) as a cased string.

Declaration
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Parameters
Type Name Description
Newtonsoft.Json.JsonWriter writer

The Newtonsoft.Json.JsonWriter to write to.

System.Object value

The value

Newtonsoft.Json.JsonSerializer serializer

The calling serializer.