Converts arbitrary values into objects specific by TypeCodes. For each TypeCode this class calls corresponding converter which applies extended conversion rules to convert the values.
More...
|
static bool | IsPrimitiveType (object obj) |
|
static bool | IsPrimitiveType (Type type) |
|
static TypeCode | ToTypeCode (Type type) |
| Gets TypeCode for specific type. More...
|
|
static TypeCode | ToTypeCode (object value) |
| Gets TypeCode for specific value. More...
|
|
static T | ToNullableType< T > (object value) |
| Converts value into an object type specified by Type Code or returns null when conversion is not possible. More...
|
|
static T | ToType< T > (object value) |
| Converts value into an object type specified by Type Code or returns type default when conversion is not possible. More...
|
|
static T | ToTypeWithDefault< T > (object value, T defaultValue) |
| Converts value into an object type specified by Type Code or returns default value when conversion is not possible. More...
|
|
static String | ToString (TypeCode type) |
| Converts a TypeCode into its string name. More...
|
|
Converts arbitrary values into objects specific by TypeCodes. For each TypeCode this class calls corresponding converter which applies extended conversion rules to convert the values.
var value1 = TypeConverter.toType(
TypeCode.Integer,
"123.456");
var value2 = TypeConverter.toType(
TypeCode.DateTime, 123);
var value3 = TypeConverter.toType(
TypeCode.Boolean,
"F");
◆ ToNullableType< T >()
static T PipServices3.Commons.Convert.TypeConverter.ToNullableType< T > |
( |
object |
value | ) |
|
|
static |
Converts value into an object type specified by Type Code or returns null when conversion is not possible.
- Template Parameters
-
T | the Class type for the data type. |
- Parameters
-
value | the value to convert. |
- Returns
- object value of type corresponding to TypeCode, or null when conversion is not supported.
See TypeConverter.ToTypeCode(Type)
◆ ToString()
static String PipServices3.Commons.Convert.TypeConverter.ToString |
( |
TypeCode |
type | ) |
|
|
static |
Converts a TypeCode into its string name.
- Parameters
-
type | the TypeCode to convert into a string. |
- Returns
- the name of the TypeCode passed as a string value.
◆ ToType< T >()
static T PipServices3.Commons.Convert.TypeConverter.ToType< T > |
( |
object |
value | ) |
|
|
static |
Converts value into an object type specified by Type Code or returns type default when conversion is not possible.
- Template Parameters
-
T | the Class type for the data type into which 'value' is to be converted. |
- Parameters
-
value | the value to convert |
- Returns
- object value of type corresponding to TypeCode, or type default when conversion is not supported.
See ToTypeWithDefault<T>(object, T)
◆ ToTypeCode() [1/2]
static TypeCode PipServices3.Commons.Convert.TypeConverter.ToTypeCode |
( |
Type |
type | ) |
|
|
static |
Gets TypeCode for specific type.
- Parameters
-
type | the Class type for the data type. |
- Returns
- the TypeCode that corresponds to the passed object's type.
◆ ToTypeCode() [2/2]
static TypeCode PipServices3.Commons.Convert.TypeConverter.ToTypeCode |
( |
object |
value | ) |
|
|
static |
Gets TypeCode for specific value.
- Parameters
-
value | value whose TypeCode is to be resolved. |
- Returns
- the TypeCode that corresponds to the passed object's type.
◆ ToTypeWithDefault< T >()
static T PipServices3.Commons.Convert.TypeConverter.ToTypeWithDefault< T > |
( |
object |
value, |
|
|
T |
defaultValue |
|
) |
| |
|
static |
Converts value into an object type specified by Type Code or returns default value when conversion is not possible.
- Template Parameters
-
T | the Class type for the data type into which 'value' is to be converted. |
- Parameters
-
value | the value to convert. |
defaultValue | the default value to return if conversion is not possible (returns null). |
- Returns
- object value of type corresponding to TypeCode, or default value when conversion is not supported
The documentation for this class was generated from the following file:
- src/Convert/TypeConverter.cs