Table of Contents

ChangeTypeOrDefault Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Extensions/ObjectDecoratorExtensions.cs

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

decorator IDecorator<object>

The IDecorator<T> to extend.

fallbackResult T

The value to return when a conversion is not possible. Default is default of T.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which may be configured.

Returns

T

An object of type T equivalent to the enclosed object of the specified decorator when a conversion is possible; otherwise fallbackResult is returned.

Type Parameters

T

The 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.