ConversionAction<TSource, TTarget>

ConversionActionReferences
public sealed class ConversionAction<TSource, TTarget> : ConversionAction
A wrapper class around a ConversionDelegate<T, Q>.
TSource
TTarget

Constructors

ConversionAction

#
Create a new conversion action.
public ConversionAction(
source,
target,
merit,
explanation,
ConversionDelegate<TSource, TTarget>
method
)

Properties

Derived

Gets whether this is a derived conversion. Derived conversions are automatically added at runtime by the ConversionServer when a conversion for a less derived type can be found and tweaked to work for a more derived type.
public bool Derived { get; }
inherited fromConversionAction

Explanation

Gets the explanation (if any) attached to the conversion method.
public string Explanation { get; }
inherited fromConversionAction

Merit

The merit of this conversion step.
public Merit Merit { get; }
inherited fromConversionAction

Method

#
Gets the strongly typed conversion delegate method.
public ConversionDelegate<TSource, TTarget> Method { get; }

SourceType

Gets the input type for this conversion.
public Type SourceType { get; }
inherited fromConversionAction

TargetType

Gets the output type for this conversion.
public Type TargetType { get; }
inherited fromConversionAction

Methods

Convert

#
Perform strongly typed conversion. This method will throw if the underlying delegate throws. Use the TryConvert(TSource, TTarget) methods to add proper error handling.
public void Convert(
TSource
from,
out TTarget
to
)

ConvertWeak

#
Perform the conversion from ConversionAction.SourceType to ConversionAction.TargetType. This method will throw if the types do not match up, or if the underlying delegate throws. Use the ConversionAction.TryConvertWeak(object, object) methods to add proper error handling.
public override void ConvertWeak(
from,
out object
to
)

TryConvert

#
Execute a conversion action with error handling.
public bool TryConvert(
TSource
source,
out TTarget
target,
out string
failure
)

TryConvert

#
Execute a conversion action with error handling.
public bool TryConvert(
TSource
source,
out TTarget
target
)

TryConvertWeak

Execute the conversion with error handling.
public bool TryConvertWeak(
source,
out object
target,
out string
failure
)
inherited fromConversionAction

TryConvertWeak

Execute the conversion with error handling.
public bool TryConvertWeak(
source,
out object
target
)
inherited fromConversionAction