Table of Contents

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

value object

Value to convert.

targetType Type

Type to convert to.

Returns

object

Converted value.

Exceptions

InvalidCastException

Occurs when the type conversion between value type and targetType is not supported.

RegisterConverter(Type, Type, IValueConverter)

Registers the type converter using runtime types definitions.

void RegisterConverter(Type from, Type to, IValueConverter converter)

Parameters

from Type

Source type to convert from.

to Type

Target type to convert to.

converter IValueConverter

The 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

converter IValueConverter<TSource, TTarget>

The converter instance to register.

Type Parameters

TSource

Source type to convert from.

TTarget

Target type to convert to.