Table of Contents

Class EnumDescriptionConverter<T>

Namespace
NanoByte.Common.Values.Design
Assembly
NanoByte.Common.dll

Type converter for Enums annotated with DescriptionAttributes.

public class EnumDescriptionConverter<T> : TypeConverter where T : struct

Type Parameters

T

The type the converter is used for.

Inheritance
object
EnumDescriptionConverter<T>
Inherited Members
Extension Methods

Examples

Add this attribute to the Enum:

[TypeConverter(typeof(DescriptionEnumConverter<NameOfEnum>))]

Remarks

Description is used as the case-insensitive string representation (falls back to element name).

Constructors

EnumDescriptionConverter()

public EnumDescriptionConverter()

Methods

CanConvertFrom(ITypeDescriptorContext?, Type)

public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)

Parameters

context ITypeDescriptorContext
sourceType Type

Returns

bool

ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)

public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)

Parameters

context ITypeDescriptorContext
culture CultureInfo
value object

Returns

object

ConvertTo(ITypeDescriptorContext?, CultureInfo?, object?, Type)

public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)

Parameters

context ITypeDescriptorContext
culture CultureInfo
value object
destinationType Type

Returns

object