Class Converter
Type conversion manager.
public static class Converter
- Inheritance
-
Converter
Methods
ChangeType(object?, Type, MappingSchema?, ConversionType)
Converts value to toConvertType
type.
public static object? ChangeType(object? value, Type toConvertType, MappingSchema? mappingSchema = null, ConversionType conversionType = ConversionType.Common)
Parameters
value
objectValue to convert.
toConvertType
TypeTarget conversion type.
mappingSchema
MappingSchemaOptional mapping schema.
conversionType
ConversionTypeConversion type. See ConversionType for details.
Returns
- object
Converted value.
ChangeTypeTo<T>(object?, MappingSchema?, ConversionType)
Converts value to T
type.
public static T ChangeTypeTo<T>(object? value, MappingSchema? mappingSchema = null, ConversionType conversionType = ConversionType.Common)
Parameters
value
objectValue to convert.
mappingSchema
MappingSchemaOptional mapping schema.
conversionType
ConversionTypeConversion type. See ConversionType for details.
Returns
- T
Converted value.
Type Parameters
T
Target conversion type.
GetDefaultMappingFromEnumType(MappingSchema, Type)
Returns type, to which provided enumeration values should be mapped.
public static Type? GetDefaultMappingFromEnumType(MappingSchema mappingSchema, Type enumType)
Parameters
mappingSchema
MappingSchemaCurrent mapping schema
enumType
TypeEnumeration type.
Returns
- Type
Underlying mapping type.
SetConverter<TFrom, TTo>(Expression<Func<TFrom, TTo>>)
Sets custom converter from TFrom
to TTo
type.
public static void SetConverter<TFrom, TTo>(Expression<Func<TFrom, TTo>> expr)
Parameters
expr
Expression<Func<TFrom, TTo>>Converter expression.
Type Parameters
TFrom
Source conversion type.
TTo
Target conversion type.