Interface ITypeConverter
- Namespace
- Icy.Data
- Assembly
- IcyUI.dll
Represents a service that helps with generalized type conversion between all .NET types.
public interface ITypeConverter
- Extension Methods
Methods
Convert(object?, Type)
Converts specified value to the specified target type.
object? Convert(object? value, Type targetType)
Parameters
Returns
- object
Converted value.
Exceptions
- InvalidCastException
Occurs when the type conversion between
valuetype andtargetTypeis not supported.
RegisterConverter(Type, Type, IValueConverter)
Registers the type converter using runtime types definitions.
void RegisterConverter(Type from, Type to, IValueConverter converter)
Parameters
fromTypeSource type to convert from.
toTypeTarget type to convert to.
converterIValueConverterThe converter instance to register.
RegisterConverter<TSource, TTarget>(IValueConverter<TSource, TTarget>)
Registers the custom type converter to handle custom types conversion.
void RegisterConverter<TSource, TTarget>(IValueConverter<TSource, TTarget> converter)
Parameters
converterIValueConverter<TSource, TTarget>The converter instance to register.
Type Parameters
TSourceSource type to convert from.
TTargetTarget type to convert to.