ChangeTypeOrDefault Method
Definition
- Namespace
- Cuemon
- Assemblies
- Cuemon.Core.dll
ChangeTypeOrDefault<T>(IDecorator<object>, T, Action<ObjectFormattingOptions>)
Returns an object of the specified T whose value is equivalent to the enclosed object of the specified decorator.
public static T ChangeTypeOrDefault<T>(this IDecorator<object> decorator, T fallbackResult = default, Action<ObjectFormattingOptions> setup = null)
Parameters
decoratorIDecorator<object>The IDecorator<T> to extend.
fallbackResultTThe value to return when a conversion is not possible. Default is
defaultofT.setupAction<ObjectFormattingOptions>The ObjectFormattingOptions which may be configured.
Returns
- T
An object of type
Tequivalent to the enclosed object of the specifieddecoratorwhen a conversion is possible; otherwisefallbackResultis returned.
Type Parameters
TThe type of the object to return.
Remarks
This method first checks if the enclosed object of the specified decorator is compatible with T; if incompatible the method continues with ChangeType<T>(IDecorator<object>, Action<ObjectFormattingOptions>) for the operation.