TypeConverter class
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.
See TypeCode
Example
var value1 = TypeConverter.toType(TypeCode.Integer, "123.456"); // Result: 123
var value2 = TypeConverter.toType(TypeCode.DateTime, 123); // Result: DateTime(123)
var value3 = TypeConverter.toType(TypeCode.Boolean, "F"); // Result: false
Constructors
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
asString(
TypeCode type) → String -
- Converts a TypeCode into its string name.
-
type
the TypeCode to convert into a string.
- Returns the name of the TypeCode passed as a string value.
- Converts a TypeCode into its string name.
-
toNullableType<
T> (TypeCode type, dynamic value) → T -
- Converts value into an object type specified by Type Code or returns null when conversion is not possible.
-
type
the TypeCode for the data type into which 'value' is to be converted.
-
value
the value to convert.
- Returns object value of type corresponding to TypeCode, or null when conversion is not supported.
- See toTypeCode
- Converts value into an object type specified by Type Code or returns null when conversion is not possible.
-
toType<
T> (TypeCode type, dynamic value) → T -
- Converts value into an object type specified by Type Code or returns type default when conversion is not possible.
-
type
the TypeCode for the data type into which 'value' is to be converted.
-
value
the value to convert.
- Returns object value of type corresponding to TypeCode, or type default when conversion is not supported.
- See toNullableType
- See toTypeCode
- Converts value into an object type specified by Type Code or returns type default when conversion is not possible.
-
toTypeCode(
dynamic value) → TypeCode -
- Gets TypeCode for specific value.
-
value
value whose TypeCode is to be resolved.
- Returns the TypeCode that corresponds to the passed object's type.
- Gets TypeCode for specific value.
-
toTypeWithDefault<
T> (TypeCode type, dynamic value, T defaultValue) → T -
- Converts value into an object type specified by Type Code or returns default value when conversion is not possible.
-
type
the TypeCode for the data type into which 'value' is to be converted.
-
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.
- See toNullableType
- See toTypeCode
- Converts value into an object type specified by Type Code or returns default value when conversion is not possible.