Class ObjectConverter
This utility class is designed to make System.Object related conversions easier to work with.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class ObjectConverter
Methods
| Improve this DocChangeType(Object, Type)
Returns an object of the specified type and whose value is equivalent to the specified object.
Declaration
public static object ChangeType(object value, Type conversionType)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to convert the underlying type. |
System.Type | conversionType | The System.Type of object to return. |
Returns
Type | Description |
---|---|
System.Object | An object whose type is |
Remarks
What differs from the System.Convert.ChangeType(Object, Type) is, that this converter supports generics and enums somewhat automated.
ChangeType(Object, Type, IFormatProvider)
Returns an object of the specified type and whose value is equivalent to the specified object.
Declaration
public static object ChangeType(object value, Type conversionType, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to convert the underlying type. |
System.Type | conversionType | The System.Type of object to return. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.Object | An object whose type is |
Remarks
What differs from the System.Convert.ChangeType(Object, Type) is, that this converter supports generics and enums. Failover uses System.ComponentModel.TypeDescriptor.
FromString(String)
Returns a primitive object whose value is equivalent to the specified value
.
Declaration
public static object FromString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to convert the underlying type. |
Returns
Type | Description |
---|---|
System.Object | An object whose type is primitive (either System.Boolean, System.Int64 or System.Double) and whose value is equivalent to |
FromString(String, IFormatProvider)
Returns a primitive object whose value is equivalent to the specified value
.
Declaration
public static object FromString(string value, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to convert the underlying type. |
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.Object | An object whose type is primitive (either System.Boolean, System.Int64 or System.Double) and whose value is equivalent to |