Class StringToEnumValueConverter<TEnum>
- Namespace
- MADE.Data.Converters
- Assembly
- MADE.Data.Converters.dll
public class StringToEnumValueConverter<TEnum> : IValueConverter<string, TEnum> where TEnum : struct, Enum
Type Parameters
TEnumThe enum type to convert to and from.
- Inheritance
-
StringToEnumValueConverter<TEnum>
- Implements
-
IValueConverter<string, TEnum>
- 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
Methods
Convert(string, object?)
Converts the value to the TEnum type.
public TEnum Convert(string value, object? parameter = null)
Parameters
valuestringThe string value to convert.
parameterobjectThe optional parameter used to help with conversion.
Returns
- TEnum
The converted
TEnumvalue.
Exceptions
- InvalidDataConversionException
Thrown if the
valuecannot be parsed as aTEnum.
ConvertBack(TEnum, object?)
Converts the value back to a string.
public string ConvertBack(TEnum value, object? parameter = null)
Parameters
valueTEnumThe enum value to convert.
parameterobjectThe optional parameter used to help with conversion.
Returns
- string
The string representation of the
TEnumvalue.