Class ValueConvert
ValueConvert provides conversion routines for values to convert them to another type and routines for formatting values.
Inherited Members
Namespace: Syncfusion.Maui.DataSource.Extensions
Assembly: Syncfusion.Maui.DataSource.dll
Syntax
public class ValueConvert
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 |
|---|
| bool |
Methods
ChangeType(object, Type, IFormatProvider)
Converts value from one type to another using an optional IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The original value. |
| Type | type | The target type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. |
Returns
| Type | Description |
|---|---|
| object | The new value in the target type. |
ChangeType(object, Type, IFormatProvider, bool)
Converts value from one type to another using an optional IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider, bool returnDbNullIfNotValid)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The original value. |
| Type | type | The target type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. |
| bool | 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 |
|---|---|
| object | The new value in the target type. |
ChangeType(object, Type, IFormatProvider, string, bool)
Converts value from one type to another using an optional IFormatProvider.
Declaration
public static object ChangeType(object value, Type type, IFormatProvider provider, string format, bool returnDbNullIfNotValid)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The original value. |
| Type | type | The target type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. |
| string | format | Format string. |
| bool | 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 |
|---|---|
| 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 |
|---|---|---|
| object | value | The value to format. |
| Type | valueType | The value type on which formatting is based. The original value will first be converted to this type. |
| string | format | The format like in ToString(string format). |
| CultureInfo | cultureInfo | The CultureInfo for formatting the value. |
| NumberFormatInfo | numberFormatInfo | The NumberFormatInfo for formatting the value. |
Returns
| Type | Description |
|---|---|
| string | The string with the formatted text for the value. |
FormatValueWithTypeInformation(object, bool)
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 |
|---|---|---|
| object | value | Represents the string value. |
| bool | 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 |
|---|---|
| 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 |
|---|---|---|
| Type | type | The Type. |
Returns
| Type | Description |
|---|---|
| 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
[RequiresUnreferencedCode("The GetType is not trim compatible")]
public static Type GetType(string typeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | typeName | Represents the type name. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| Type | type | Represents the type. |
Returns
| Type | Description |
|---|---|
| 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 |
|---|---|---|
| string | stringValue | Represents the string value. |
Returns
| Type | Description |
|---|---|
| bool | 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 |
|---|---|---|
| string | stringValue | The text to parse. |
| Type | resultType | The requested result type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. Can be NULL. |
| string | format | A format string used in a ToString() call. Right now format is only interpreted to enable round tripping for formatted dates. |
Returns
| Type | Description |
|---|---|
| object | The new value in the target type. |
Parse(string, Type, IFormatProvider, string, bool)
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 |
|---|---|---|
| string | stringValue | The text to parse. |
| Type | resultType | The requested result type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. Can be NULL. |
| string | format | A format string used in a ToString() call. Right now format is only interpreted to enable round tripping for formatted dates. |
| bool | returnDbNullIfNotValid | Indicates whether DbNull should be returned if value cannot be parsed. Otherwise an exception is thrown. |
Returns
| Type | Description |
|---|---|
| object | The new value in the target type. |
Parse(string, Type, IFormatProvider, string[], bool)
Parse the given text using the resultTypes "Parse" method or using a type converter.
Declaration
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
public static object Parse(string stringValue, Type resultType, IFormatProvider provider, string[] formats, bool returnDbNullIfNotValid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | stringValue | The text to parse. |
| Type | resultType | The requested result type. |
| IFormatProvider | provider | A IFormatProvider used to format or parse the value. Can be NULL. |
| string[] | formats | A string array holding permissible formats used in a ToString() call. Right now formats is only interpreted to enable round tripping for formatted dates. |
| bool | returnDbNullIfNotValid | Indicates whether DbNull should be returned if value cannot be parsed. Otherwise an exception is thrown. |
Returns
| Type | Description |
|---|---|
| object | The new value in the target type. |
ParseValueWithTypeInformation(string, out object, bool)
Parses the given string including type information. String can be in format %lt;type> 'value'
Declaration
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
public static bool ParseValueWithTypeInformation(string valueAsString, out object returnValue, bool allowConvertFromBase64)
Parameters
| Type | Name | Description |
|---|---|---|
| string | valueAsString | Represents the string value. |
| object | returnValue | Represents the return value. |
| bool | 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 |
|---|---|
| bool | Returns the boolean value. |