Table of Contents

Class Caster

Namespace
Rinku.Mapping.Conversion
Assembly
Rinku.dll

Converts values through casts, numeric conversions, enum conversions, and parsing. Use AddParser<TFrom, TTo>(CastFunc<TFrom, TTo>) to replace conversion for one source and target type pair.

public static class Caster
Inheritance
Caster
Inherited Members

Methods

AddParser<TFrom, TTo>(CastFunc<TFrom, TTo>)

Registers a custom conversion from TFrom to TTo.

public static void AddParser<TFrom, TTo>(CastFunc<TFrom, TTo> parser)

Parameters

parser CastFunc<TFrom, TTo>

Type Parameters

TFrom
TTo

Parse<T>(object?)

Converts an object value to T or throws when conversion is not possible.

public static T? Parse<T>(this object? value)

Parameters

value object

Returns

T

Type Parameters

T

TryCast<TFrom, TTo>(TFrom, out TTo)

Converts value to TTo, returning false when no conversion fits.

public static bool TryCast<TFrom, TTo>(TFrom value, out TTo val)

Parameters

value TFrom
val TTo

Returns

bool

Type Parameters

TFrom
TTo