Show / Hide Table of Contents

Class EnumDescriptionJsonConverter

Serializes an Enum value to its corresponding DescriptionAttribute.

Inheritance
System.Object
EnumDescriptionJsonConverter
Namespace: Celerik.NetCore.Util
Assembly: cs.temp.dll.dll
Syntax
public class EnumDescriptionJsonConverter : JsonConverter
Examples
    enum MyEnum
    {
        [Description("Some Value")]
        SomeValue
    }

    class MyClass
    {
        // MyProp will be serialized to "Some Value".
        [JsonConverter(typeof(EnumDescriptionJsonConverter))]
        public MyEnum MyProp { get; set; } = MyEnum.SomeValue;
    }

Properties

CanRead

Gets a value indicating whether this Newtonsoft.Json.JsonConverter can read JSON.

Declaration
public override bool CanRead { get; }
Property Value
Type Description
System.Boolean

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 this instance can convert the specified object type; otherwise, false.

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
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.

JsonSerializer serializer

The calling serializer.

Returns
Type Description
System.Object

The object value.

WriteJson(JsonWriter, Object, JsonSerializer)

Writes the JSON representation of the object.

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

The Newtonsoft.Json.JsonWriter to write to.

System.Object value

The value.

JsonSerializer serializer

The calling serializer.

Exceptions
Type Condition
System.ArgumentNullException

Writer is null.

In This Article
Back to top Generated by DocFX