Class ValueConvert
ValueConvert provides conversion routines for values to convert them to another type and routines for formatting values.
Inheritance
Namespace: Syncfusion.Maui.DataSource.Extensions
Assembly: Syncfusion.Maui.DataSource.dll
Syntax
public class ValueConvert : Object
Properties
AllowFormatValueTrimEnd
Gets or sets a value indicating whether FormatValue(Object, Type, String, CultureInfo, NumberFormatInfo) should trim whitespace characters from the end of the formatted text.
Declaration
public static bool AllowFormatValueTrimEnd { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
ChangeType(Object, Type, IFormatProvider)
Converts value from one type to another using an optional System.IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The original value. |
System.Type | type | The target type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
ChangeType(Object, Type, IFormatProvider, Boolean)
Converts value from one type to another using an optional System.IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider, bool returnDbNullIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The original value. |
System.Type | type | The target type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. |
System.Boolean | returnDbNullIfNotValid | Indicates whether exceptions should be avoided or cached and return value should be DBNull if it cannot be converted to the target type. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
ChangeType(Object, Type, IFormatProvider, String, Boolean)
Converts value from one type to another using an optional System.IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider, string format, bool returnDbNullIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The original value. |
System.Type | type | The target type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. |
System.String | format | Format string. |
System.Boolean | returnDbNullIfNotValid | Indicates whether exceptions should be avoided or cached and return value should be DBNull if it cannot be converted to the target type. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
FormatValue(Object, Type, String, CultureInfo, NumberFormatInfo)
Generates display text using the specified format, culture info and number format.
Declaration
public static string FormatValue(object value, Type valueType, string format, CultureInfo cultureInfo, NumberFormatInfo numberFormatInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to format. |
System.Type | valueType | The value type on which formatting is based. The original value will first be converted to this type. |
System.String | format | The format like in ToString(string format). |
System.Globalization.CultureInfo | cultureInfo | The System.Globalization.CultureInfo for formatting the value. |
System.Globalization.NumberFormatInfo | numberFormatInfo | The System.Globalization.NumberFormatInfo for formatting the value. |
Returns
Type | Description |
---|---|
System.String | The string with the formatted text for the value. |
FormatValueWithTypeInformation(Object, Boolean)
Formats the given value as string including type information. String will be in format %lt;type> 'value'
Declaration
public static string FormatValueWithTypeInformation(object value, bool allowConvertToBase64)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Represents the string value. |
System.Boolean | allowConvertToBase64 | Indicates whether TypeConverter should be checked whether the type to be parsed supports conversion to/from byte array (e.g. an Image) |
Returns
Type | Description |
---|---|
System.String | Returns the string value. |
GetDefaultValue(Type)
Returns a representative value for any given type.
Declaration
public static object GetDefaultValue(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type. |
Returns
Type | Description |
---|---|
System.Object | A value with the specified type. |
GetType(String)
Returns the type from the specified name. If an assembly name is appended the list of currently loaded assemblies in the current AppDomain are checked.
Declaration
public static Type GetType(string typeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeName | Represents the type name. |
Returns
Type | Description |
---|---|
System.Type | Returns the assembly name. |
GetTypeName(Type)
Returns the type name. If type is not in microsoft corporation library, the assembly name is appended.
Declaration
public static string GetTypeName(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Represents the type. |
Returns
Type | Description |
---|---|
System.String | Returns the assembly type. |
IsEmpty(String)
Indicates whether string is null or empty.
Declaration
public static bool IsEmpty(string stringValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | Represents the string value. |
Returns
Type | Description |
---|---|
System.Boolean | Returns the boolean value. |
Parse(String, Type, IFormatProvider, String)
Parses the given text using the resultTypes "Parse" method or using a type converter.
Declaration
public static object Parse(string stringValue, Type resultType, IFormatProvider provider, string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | The text to parse. |
System.Type | resultType | The requested result type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. Can be NULL. |
System.String | format | A format string used in a System.Object.ToString call. Right now format is only interpreted to enable round tripping for formatted dates. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
Parse(String, Type, IFormatProvider, String, Boolean)
Parse the given text using the resultTypes "Parse" method or using a type converter.
Declaration
public static object Parse(string stringValue, Type resultType, IFormatProvider provider, string format, bool returnDbNullIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | The text to parse. |
System.Type | resultType | The requested result type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. Can be NULL. |
System.String | format | A format string used in a System.Object.ToString call. Right now format is only interpreted to enable round tripping for formatted dates. |
System.Boolean | returnDbNullIfNotValid | Indicates whether DbNull should be returned if value cannot be parsed. Otherwise an exception is thrown. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
Parse(String, Type, IFormatProvider, String[], Boolean)
Parse the given text using the resultTypes "Parse" method or using a type converter.
Declaration
public static object Parse(string stringValue, Type resultType, IFormatProvider provider, string[] formats, bool returnDbNullIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringValue | The text to parse. |
System.Type | resultType | The requested result type. |
System.IFormatProvider | provider | A System.IFormatProvider used to format or parse the value. Can be NULL. |
System.String[] | formats | A string array holding permissible formats used in a System.Object.ToString call. Right now formats is only interpreted to enable round tripping for formatted dates. |
System.Boolean | returnDbNullIfNotValid | Indicates whether DbNull should be returned if value cannot be parsed. Otherwise an exception is thrown. |
Returns
Type | Description |
---|---|
System.Object | The new value in the target type. |
ParseValueWithTypeInformation(String, out Object, Boolean)
Parses the given string including type information. String can be in format %lt;type> 'value'
Declaration
public static bool ParseValueWithTypeInformation(string valueAsString, out object returnValue, bool allowConvertFromBase64)
Parameters
Type | Name | Description |
---|---|---|
System.String | valueAsString | Represents the string value. |
System.Object | returnValue | Represents the return value. |
System.Boolean | allowConvertFromBase64 | Indicates whether TypeConverter should be checked whether the type to be parsed supports conversion to/from byte array (e.g. an Image) |
Returns
Type | Description |
---|---|
System.Boolean | Returns the boolean value. |