Click or drag to resize

ExtensionsConvertions Class

Provides usefull extension methods
Inheritance Hierarchy
SystemObject
  CauldronExtensionsConvertions

Namespace:  Cauldron
Assembly:  Cauldron (in Cauldron.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static class ExtensionsConvertions

The ExtensionsConvertions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleAs(Object, Type)
Converts a type using the implicit or explicit operators. If both fails it will try to convert the value with ChangeType(Object, Type).
Public methodStatic memberCode exampleAs(Object, Type, Type)
Converts a type using the implicit or explicit operators. If both fails it will try to convert the value with ChangeType(Object, Type).
Public methodStatic memberCode exampleAsT(Object)
Performs a cast between compatible reference types. If a convertion is not possible then null is returned. As a last resort it will use ChangeType(Object, Type).

Tries to use the implicit and explicit operators if exists when convertion with 'as' returns null.

Public methodStatic memberAsReadOnlyTKey, TValue
Public methodStatic memberConvert(String, Type)
Converts a string to the type defined by targetType
Public methodStatic memberConvert(Byte, Encodings, Encodings)
Converts a string represented by a byte array from a encoding to another encoding
Public methodStatic memberConvert(String, Encodings, Encodings)
Converts a string from a encoding to another encoding
Public methodStatic memberConvert(String, Type, NumberFormatInfo)
Converts a string to the type defined by targetType
Public methodStatic memberConvertT(String)
Converts a string to the type defined by T
Public methodStatic memberConvertT(String, NumberFormatInfo)
Converts a string to the type defined by T
Public methodStatic memberConvertEscapeSequences
Converts the readable escaped chars in a string to its equivalent char. This includes simple-escape-sequences such as \' \" \\ \0 \a \b \f \n \r \t \v
Public methodStatic memberConvertToBytes
Converts a string from a encoding to another encoding
Public methodStatic memberToArray
Converts a IEnumerable to an array
Public methodStatic memberToBase64String
Converts a string to its equivalent string representation that is encoded with base-64 digits.
Public methodStatic memberToBool
Converts a string to bool.

This will first try to compare the string to "true" or "y" and then to "false" or "n". If both fails then it will use TryParse(String, Boolean) to parse the string to bool. If that also fails then the string will be compared to "1".

Public methodStatic memberToByte
Converts the value to a byte If convertion fails the value will always be 0
Public methodStatic memberToBytes(Double)
Converts the value to a byte array
Public methodStatic memberToBytes(Int32)
Converts the value to a byte array
Public methodStatic memberToBytes(Int64)
Converts the value to a byte array
Public methodStatic memberToBytes(Single)
Converts the value to a byte array
Public methodStatic memberToBytes(UInt32)
Converts the value to a byte array
Public methodStatic memberToBytesAsync
Converts a Stream to Byte array. If the stream is not seekable, then this will use ReadToEndAsync to get the stream.
Public methodStatic memberToChar
Converts the value to a char. If convertion fails the value will always be '\0'
Public methodStatic memberToDecimal(String)
Tries to convert a String to an Decimal. Returns MinusOne if target cannot be parsed.
Public methodStatic memberToDecimal(String, NumberFormatInfo)
Tries to convert a String to an Decimal. Returns MinusOne if target cannot be parsed.
Public methodStatic memberToDecimalUS
Tries to convert a String to an Decimal using the en-US number format. Returns 0 if target cannot be parsed.
Public methodStatic memberToDouble(Byte)
Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array.
Public methodStatic memberToDouble(String)
Converts the string representation of a number in a specified culture-specific format to its double-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToDouble(String, NumberFormatInfo)
Converts the string representation of a number in a specified culture-specific format to its double-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToDoubleUS
Converts the string representation of a number in the en-US format to its double-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToFloat(Byte)
Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.
Public methodStatic memberToFloat(String)
Converts the string representation of a number in a specified style and culture-specific format to its single-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToFloat(String, NumberFormatInfo)
Converts the string representation of a number in a specified style and culture-specific format to its single-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToFloatUS
Converts the string representation of a number in a the en-US format format to its single-precision floating-point number equivalent. if the string content is "nan" then a NaN is returned. Returns 0 if target cannot be parsed.
Public methodStatic memberToInteger(Byte)
Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.
Public methodStatic memberToInteger(String)
Tries to convert a String to an Int32. Returns MinValue if target cannot be parsed.
Public methodStatic memberToInteger(String, NumberFormatInfo)
Tries to convert a String to an Int32. Returns MinValue if target cannot be parsed.
Public methodStatic memberToIntegerUS
Tries to convert a String to an Int32 using the en-US number format. Returns MinValue if target cannot be parsed.
Public methodStatic memberToLong(Byte)
Returns a long converted from eight bytes.
Public methodStatic memberToLong(Object)
Tries to convert a Object to an Int64. Returns MinValue if target cannot be parsed.
Public methodStatic memberToLong(String)
Tries to convert a String to an Int64. Returns MinValue if target cannot be parsed.
Public methodStatic memberToLong(String, NumberFormatInfo)
Tries to convert a String to an Int64. Returns MinValue if target cannot be parsed.
Public methodStatic memberToLongUS
Tries to convert a String to an Int64 using the en-US number format. Returns MinValue if target cannot be parsed.
Public methodStatic memberToOrdinalDate
Converts a DateTime to ordinal date. An ordinal date is a calendar date typically consisting of a year and a day of year ranging between 1 and 366 (starting on January 1).
Public methodStatic memberToShort(String)
Tries to convert a String to an Int16. Returns MinValue if target cannot be parsed.
Public methodStatic memberToShort(String, NumberFormatInfo)
Tries to convert a String to an Int16. Returns MinValue if target cannot be parsed.
Public methodStatic memberToShortUS
Tries to convert a String to an Int16 using the en-US number format. Returns MinValue if target cannot be parsed.
Public methodStatic memberToString(String, Object)
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array. This also takes into account that source can be an inline text for the TextBlock. CurrentCulture is used as IFormatProvider
Public methodStatic memberToString(String, IFormatProvider, Object)
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array. This also takes into account that source can be an inline text for the TextBlock
Public methodStatic memberToUInteger(String)
Tries to convert a String to an UInt32. Returns MinValue if target cannot be parsed.
Public methodStatic memberToUInteger(String, NumberFormatInfo)
Tries to convert a String to an UInt32. Returns MinValue if target cannot be parsed.
Public methodStatic memberToUIntegerUS
Tries to convert a String to an UInt32 using the en-US number format. Returns MinValue if target cannot be parsed.
Public methodStatic memberToULong(String)
Tries to convert a String to an UInt64. Returns MinValue if target cannot be parsed.
Public methodStatic memberToULong(String, NumberFormatInfo)
Tries to convert a String to an UInt64. Returns MinValue if target cannot be parsed.
Public methodStatic memberToULongUS
Tries to convert a String to an UInt64 using the en-US number format. Returns MinValue if target cannot be parsed.
Public methodStatic memberToUShort(Byte)
Returns a 16-bit signed integer converted from four bytes at a specified position in a byte array.
Public methodStatic memberToUShort(String)
Tries to convert a String to an UInt16. Returns MinValue if target cannot be parsed.
Public methodStatic memberToUShort(String, NumberFormatInfo)
Tries to convert a String to an UInt16. Returns MinValue if target cannot be parsed.
Public methodStatic memberToUShortUS
Tries to convert a String to an UInt16 using the en-US number format. Returns MinValue if target cannot be parsed.
Top
See Also