Table of Contents

ChangeType Method

Definition

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

ChangeType<T>(IDecorator<object>, Action<ObjectFormattingOptions>)

Returns an object of the specified T whose value is equivalent to the enclosed object of the specified decorator.

public static T ChangeType<T>(this IDecorator<object> decorator, Action<ObjectFormattingOptions> setup = null)

Parameters

decorator IDecorator<object>

The IDecorator<T> to extend.

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.

Type Parameters

T

The type of the object to return.

Remarks

What differs from the ChangeType(object, Type) is, that this converter supports generics and enums. Fallback uses TypeDescriptor and checks if the underlying IFormatProvider of FormatProvider is a CultureInfo, then this will be used in the conversion together with DescriptorContext.

Exceptions

ArgumentNullException

decorator cannot be null.

AggregateException

The enclosed object of decorator could not be converted.

See Also
ChangeType(object, Type)

ChangeType(IDecorator<object>, Type, Action<ObjectFormattingOptions>)

Returns an object of a specified targetType whose value is equivalent to the enclosed object of the specified decorator.

public static object ChangeType(this IDecorator<object> decorator, Type targetType, Action<ObjectFormattingOptions> setup = null)

Parameters

decorator IDecorator<object>

The IDecorator<T> to extend.

targetType Type

The type of the object to return.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which may be configured.

Returns

object

An object of type targetType equivalent to the enclosed object of the specified decorator.

Remarks

What differs from the ChangeType(object, Type) is, that this converter supports generics and enums. Fallback uses TypeDescriptor and checks if the underlying IFormatProvider of FormatProvider is a CultureInfo, then this will be used in the conversion together with DescriptorContext.

Exceptions

ArgumentNullException

decorator cannot be null.

AggregateException

The enclosed object of decorator could not be converted.

See Also
ChangeType(object, Type)