Table of Contents

Class StringToEnumValueConverter<TEnum>

Namespace
MADE.Data.Converters
Assembly
MADE.Data.Converters.dll

Defines a value converter from string to an Enum type.

public class StringToEnumValueConverter<TEnum> : IValueConverter<string, TEnum> where TEnum : struct, Enum

Type Parameters

TEnum

The enum type to convert to and from.

Inheritance
StringToEnumValueConverter<TEnum>
Implements
Inherited Members
Extension Methods

Properties

IgnoreCase

Gets or sets a value indicating whether the conversion should ignore case. Default is true.

public bool IgnoreCase { get; set; }

Property Value

bool

Methods

Convert(string, object?)

Converts the value to the TEnum type.

public TEnum Convert(string value, object? parameter = null)

Parameters

value string

The string value to convert.

parameter object

The optional parameter used to help with conversion.

Returns

TEnum

The converted TEnum value.

Exceptions

InvalidDataConversionException

Thrown if the value cannot be parsed as a TEnum.

ConvertBack(TEnum, object?)

Converts the value back to a string.

public string ConvertBack(TEnum value, object? parameter = null)

Parameters

value TEnum

The enum value to convert.

parameter object

The optional parameter used to help with conversion.

Returns

string

The string representation of the TEnum value.