ChangeType Method
Definition
- Namespace
- Cuemon
- Assemblies
- Cuemon.Core.dll
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
decoratorIDecorator<object>The IDecorator<T> to extend.
setupAction<ObjectFormattingOptions>The ObjectFormattingOptions which may be configured.
Returns
- T
An object of type
Tequivalent to the enclosed object of the specifieddecorator.
Type Parameters
TThe 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
decoratorcannot be null.- AggregateException
The enclosed object of
decoratorcould not be converted.
- See Also
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
decoratorIDecorator<object>The IDecorator<T> to extend.
targetTypeTypeThe type of the object to return.
setupAction<ObjectFormattingOptions>The ObjectFormattingOptions which may be configured.
Returns
- object
An object of type
targetTypeequivalent to the enclosed object of the specifieddecorator.
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
decoratorcannot be null.- AggregateException
The enclosed object of
decoratorcould not be converted.
- See Also