Class ValueConvert
ValueConvert provides conversion routines for values to convert them to another type and routines for formatting values.
Inheritance
Namespace: Syncfusion.UI.Xaml.CellGrid.Styles
Assembly: Syncfusion.SfCellGrid.WPF.dll
Syntax
public class ValueConvert : Object
Properties
AllowFormatValueTrimEnd
Indicates whether FormatValue(Object, Type, String, CultureInfo, NumberFormatInfo, IFormatProvider) 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 catched 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 catched 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, IFormatProvider)
Generates display text using the specified format, culture info and number format.
Declaration
public static string FormatValue(object value, Type valueType, string format, CultureInfo ci, NumberFormatInfo nfi, IFormatProvider FormatProvider)
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 | ci | The System.Globalization.CultureInfo for formatting the value. |
System.Globalization.NumberFormatInfo | nfi | The System.Globalization.NumberFormatInfo for formatting the value. |
System.IFormatProvider | FormatProvider |
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 | |
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 |
---|
System.String |
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 |
Returns
Type |
---|
System.Type |
GetTypeName(Type)
Returns the type name. If type is not in mscorlib, the assembly name is appended.
Declaration
public static string GetTypeName(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type |
---|
System.String |
IsEmpty(String)
Indicates whether string is null or empty.
Declaration
public static bool IsEmpty(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str |
Returns
Type |
---|
System.Boolean |
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 s, Type resultType, IFormatProvider provider, string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | 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 roundtripping 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 s, Type resultType, IFormatProvider provider, string format, bool returnDbNUllIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | 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 roundtripping 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 s, Type resultType, IFormatProvider provider, string[] formats, bool returnDbNUllIfNotValid)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | 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 roundtripping 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 retVal, bool allowConvertFromBase64)
Parameters
Type | Name | Description |
---|---|---|
System.String | valueAsString | |
System.Object | retVal | |
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 |
---|
System.Boolean |
TryConvertFromBase64String(Type, String, out Object)
Indicates whether the TypeConverter associated with the type supports conversion to/from a byte array (e.g. an Image). If that is the case the string is converted to a byte array from a base64 string.
Declaration
public static bool TryConvertFromBase64String(Type type, string valueAsString, out object retVal)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
System.String | valueAsString | |
System.Object | retVal |
Returns
Type |
---|
System.Boolean |
TryConvertToBase64String(Object)
Indicates whether the TypeConverter associated with the type supports conversion to/from a byte array (e.g. an Image). If that is the case the string is converted to a base64 string from a byte array.
Declaration
public static string TryConvertToBase64String(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type |
---|
System.String |