ConversionAction<TSource, TTarget>

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

Constructors

ConversionAction

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

Properties

Derived

public bool Derived { get; }
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.
inherited fromConversionAction

Explanation

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

Merit

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

Method

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

SourceType

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

TargetType

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

Methods

Convert

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

ConvertWeak

#
public override void ConvertWeak(object from, out object to)
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.
from (object)
to (out object)

TryConvert

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

TryConvert

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

TryConvertWeak

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

TryConvertWeak

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