Class Conversions
- Namespace
- Alis.Core.Aspect.Data.Json
- Assembly
- Alis.dll
The conversions class
internal static class ConversionsInheritance
Inherited Members
Fields
EnumSeparators
The enum separators
internal static readonly char[] EnumSeparatorsField Value
- char[]
Methods
CanGetEnumNamesAndValues(Type, out string[], out Array)
Describes whether can get enum names and values
internal static bool CanGetEnumNamesAndValues(Type type, out string[] names, out Array values)Parameters
Returns
- bool
-
The bool
CanParseTokens(string, Type, string[], Array, out object)
Describes whether can parse tokens
internal static bool CanParseTokens(string input, Type type, string[] names, Array values, out object value)Parameters
inputstring-
The input
typeType-
The type
namesstring[]-
The names
valuesArray-
The values
valueobject-
The value
Returns
- bool
-
The bool
ChangeType<T>(object, T, IFormatProvider)
Changes the type using the specified input
public static T ChangeType<T>(object input, T defaultValue = default, IFormatProvider provider = null)Parameters
inputobject-
The input
defaultValueT-
The default value
providerIFormatProvider-
The provider
Returns
- T
-
The value
Type Parameters
T-
The
ChangeType(object, Type, object, IFormatProvider)
Changes the type using the specified input
public static object ChangeType(object input, Type conversionType, object defaultValue = null, IFormatProvider provider = null)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
defaultValueobject-
The default value
providerIFormatProvider-
The provider
Returns
- object
-
The value
ConvertToEnum(Type, string)
Converts the to enum using the specified type
internal static object ConvertToEnum(Type type, string input)Parameters
Returns
- object
-
The object
ConvertToEnum(Type, object)
Converts the to enum using the specified enum type
internal static object ConvertToEnum(Type enumType, object value)Parameters
Returns
- object
-
The object
ConvertTokenValueToUlong(object)
Converts the token value to ulong using the specified token value
internal static ulong ConvertTokenValueToUlong(object tokenValue)Parameters
tokenValueobject-
The token value
Returns
- ulong
-
The ulong
CreateInstance(Type)
Creates the instance using the specified type
internal static object CreateInstance(Type type)Parameters
typeType-
The type
Returns
- object
-
The object
EnumToObject(Type, object)
Enums the to object using the specified enum type
internal static object EnumToObject(Type enumType, object value)Parameters
Returns
- object
-
The object
EnumToUInt64(object)
Enums the to u int 64 using the specified value
internal static ulong EnumToUInt64(object value)Parameters
valueobject-
The value
Returns
- ulong
-
The ulong
Exceptions
EnumTryParse(Type, object, out object)
Describes whether enum try parse
internal static bool EnumTryParse(Type type, object input, out object value)Parameters
Returns
- bool
-
The bool
FormatInput(object)
Formats the input using the specified input
internal static string FormatInput(object input)Parameters
inputobject-
The input
Returns
- string
-
The string
GetConverter(Type)
Gets the type converter for the specified type.
internal static TypeConverter GetConverter(Type type)Parameters
typeType-
The type to get the converter for.
Returns
- TypeConverter
-
The type converter for the specified type.
IsArrayOrGenericList(Type, out Type)
Describes whether is array or generic list
internal static bool IsArrayOrGenericList(Type conversionType, out Type elementType)Parameters
Returns
- bool
-
The bool
IsBool(Type)
Describes whether is bool
internal static bool IsBool(Type conversionType)Parameters
conversionTypeType-
The conversion type
Returns
- bool
-
The bool
IsConvertible(object, out IConvertible)
Describes whether is convertible
internal static bool IsConvertible(object input, out IConvertible convertible)Parameters
inputobject-
The input
convertibleIConvertible-
The convertible
Returns
- bool
-
The bool
IsCultureInfoOrFormatProvider(Type)
Describes whether is culture info or format provider
internal static bool IsCultureInfoOrFormatProvider(Type conversionType)Parameters
conversionTypeType-
The conversion type
Returns
- bool
-
The bool
IsDateTimeType(Type)
Describes whether is date time type
internal static bool IsDateTimeType(Type conversionType)Parameters
conversionTypeType-
The conversion type
Returns
- bool
-
The bool
IsGenericList(Type, out Type)
Describes whether is generic list
internal static bool IsGenericList(Type type, out Type elementType)Parameters
Returns
- bool
-
The bool
Exceptions
IsHexadecimalAndCanBeParsed(string, Type, out object)
Describes whether is hexadecimal and can be parsed
internal static bool IsHexadecimalAndCanBeParsed(string input, Type type, out object value)Parameters
Returns
- bool
-
The bool
IsInputNegative(string)
Describes whether is input negative
internal static bool IsInputNegative(string input)Parameters
inputstring-
The input
Returns
- bool
-
The bool
IsInvalid(Type, object)
Describes whether is invalid
internal static bool IsInvalid(Type enumType, object value)Parameters
Returns
- bool
-
The bool
IsNullable(Type)
Describes whether is nullable
internal static bool IsNullable(Type type)Parameters
typeType-
The type
Returns
- bool
-
The bool
Exceptions
IsNumericType(Type)
Describes whether is numeric type
internal static bool IsNumericType(Type conversionType)Parameters
conversionTypeType-
The conversion type
Returns
- bool
-
The bool
IsReallyValueType(Type)
Describes whether is really value type
internal static bool IsReallyValueType(Type type)Parameters
typeType-
The type
Returns
- bool
-
The bool
Exceptions
IsTokenNull(string)
Describes whether is token null
internal static bool IsTokenNull(string sanitizedToken)Parameters
sanitizedTokenstring-
The sanitized token
Returns
- bool
-
The bool
IsValid(DateTime)
Describes whether is valid
internal static bool IsValid(DateTime dt)Parameters
dtDateTime-
The dt
Returns
- bool
-
The bool
IsValidInput(Type, object)
Describes whether is valid input
internal static bool IsValidInput(Type type, object input)Parameters
Returns
- bool
-
The bool
MatchNegativeInput(string, object)
Describes whether match negative input
internal static bool MatchNegativeInput(string input, object valueI)Parameters
Returns
- bool
-
The bool
MatchPositiveInput(string, object)
Describes whether match positive input
internal static bool MatchPositiveInput(string input, object valueI)Parameters
Returns
- bool
-
The bool
ParseEnum(Type, string)
Parses the enum using the specified enum type
internal static object ParseEnum(Type enumType, string stringValue)Parameters
Returns
- object
-
The object
SanitizeToken(string)
Sanitizes the token using the specified token
internal static string SanitizeToken(string token)Parameters
tokenstring-
The token
Returns
- string
-
The string
StartsWithDigitOrSign(string)
Describes whether starts with digit or sign
internal static bool StartsWithDigitOrSign(string input)Parameters
inputstring-
The input
Returns
- bool
-
The bool
ToEnum(string, Type)
Returns the enum using the specified text
internal static object ToEnum(string text, Type enumType)Parameters
Returns
- object
-
The value
Exceptions
TryChangeBasedOnConversionType(object, Type, IFormatProvider, Type, out object)
Describes whether try change based on conversion type
internal static bool TryChangeBasedOnConversionType(object input, Type conversionType, IFormatProvider provider, Type inputType, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
providerIFormatProvider-
The provider
inputTypeType-
The input type
valueobject-
The value
Returns
- bool
-
The bool
TryChangeBasedOnOtherTypes(object, Type, IFormatProvider, Type, out object)
Describes whether try change based on other types
internal static bool TryChangeBasedOnOtherTypes(object input, Type conversionType, IFormatProvider provider, Type inputType, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
providerIFormatProvider-
The provider
inputTypeType-
The input type
valueobject-
The value
Returns
- bool
-
The bool
TryChangeFromEnum(Type, object, out object)
Describes whether try change from enum
internal static bool TryChangeFromEnum(Type conversionType, object input, out object value)Parameters
Returns
- bool
-
The bool
TryChangeToBool(object, IFormatProvider, out object)
Describes whether try change to bool
internal static bool TryChangeToBool(object input, IFormatProvider provider, out object value)Parameters
inputobject-
The input
providerIFormatProvider-
The provider
valueobject-
The value
Returns
- bool
-
The bool
TryChangeToCollection(object, Type, Type, out object)
Describes whether try change to collection
internal static bool TryChangeToCollection(object input, Type conversionType, Type elementType, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
elementTypeType-
The element type
valueobject-
The value
Returns
- bool
-
The bool
TryChangeToCultureInfo(object, out object)
Describes whether try change to culture info
internal static bool TryChangeToCultureInfo(object input, out object value)Parameters
Returns
- bool
-
The bool
TryChangeToDateTime(object, Type, Type, out object)
Describes whether try change to date time
internal static bool TryChangeToDateTime(object input, Type conversionType, Type inputType, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
inputTypeType-
The input type
valueobject-
The value
Returns
- bool
-
The bool
TryChangeToEnum(Type, object, out object)
Describes whether try change to enum
internal static bool TryChangeToEnum(Type conversionType, object input, out object value)Parameters
Returns
- bool
-
The bool
TryChangeToGuid(object, IFormatProvider, out object)
Describes whether try change to guid
internal static bool TryChangeToGuid(object input, IFormatProvider provider, out object value)Parameters
inputobject-
The input
providerIFormatProvider-
The provider
valueobject-
The value
Returns
- bool
-
The bool
TryChangeToIntPtr(object, out object)
Describes whether try change to int ptr
internal static bool TryChangeToIntPtr(object input, out object value)Parameters
Returns
- bool
-
The bool
TryChangeToNullable(object, Type, IFormatProvider, out object)
Attempts to convert the input to a nullable type.
internal static bool TryChangeToNullable(object input, Type conversionType, IFormatProvider provider, out object value)Parameters
inputobject-
The input to convert.
conversionTypeType-
The type to convert to.
providerIFormatProvider-
The format provider to use for conversion.
valueobject-
The converted value.
Returns
- bool
-
True if the conversion was successful, otherwise false.
TryChangeToNumeric(object, Type, out object)
Describes whether try change to numeric
internal static bool TryChangeToNumeric(object input, Type conversionType, out object value)Parameters
Returns
- bool
-
The bool
TryChangeToTimeSpan(object, IFormatProvider, out object)
Describes whether try change to time span
internal static bool TryChangeToTimeSpan(object input, IFormatProvider provider, out object value)Parameters
inputobject-
The input
providerIFormatProvider-
The provider
valueobject-
The value
Returns
- bool
-
The bool
TryChangeType<T>(object, out T)
Describes whether try change type
public static bool TryChangeType<T>(object input, out T value)Parameters
inputobject-
The input
valueT-
The value
Returns
- bool
-
The bool
Type Parameters
T-
The
TryChangeType<T>(object, IFormatProvider, out T)
Describes whether try change type
internal static bool TryChangeType<T>(object input, IFormatProvider provider, out T value)Parameters
inputobject-
The input
providerIFormatProvider-
The provider
valueT-
The value
Returns
- bool
-
The bool
Type Parameters
T-
The
TryChangeType(object, Type, out object)
Describes whether try change type
public static bool TryChangeType(object input, Type conversionType, out object value)Parameters
Returns
- bool
-
The bool
TryChangeType(object, Type, IFormatProvider, out object)
Describes whether try change type
internal static bool TryChangeType(object input, Type conversionType, IFormatProvider provider, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
providerIFormatProvider-
The provider
valueobject-
The value
Returns
- bool
-
The bool
Exceptions
TryChangeTypeBasedOnInputType(object, Type, IFormatProvider, Type, out object)
Describes whether try change type based on input type
internal static bool TryChangeTypeBasedOnInputType(object input, Type conversionType, IFormatProvider provider, Type inputType, out object value)Parameters
inputobject-
The input
conversionTypeType-
The conversion type
providerIFormatProvider-
The provider
inputTypeType-
The input type
valueobject-
The value
Returns
- bool
-
The bool
TryChangeWithIConvertible(IConvertible, Type, IFormatProvider, out object)
Describes whether try change with i convertible
internal static bool TryChangeWithIConvertible(IConvertible input, Type conversionType, IFormatProvider provider, out object value)Parameters
inputIConvertible-
The input
conversionTypeType-
The conversion type
providerIFormatProvider-
The provider
valueobject-
The value
Returns
- bool
-
The bool
TryConvert(object, Type, Type, out object)
Tries to convert the input value to the target type.
internal static bool TryConvert(object value, Type target, Type source, out object result)Parameters
valueobject-
The value to convert.
targetType-
The target type to convert to.
sourceType-
The source type of the value.
resultobject-
The result of the conversion.
Returns
- bool
-
True if the conversion was successful, false otherwise.
TryConvertToEnumAndAssignValue(Type, string, out object)
Tries to convert the input to an enum and assign it to the value.
internal static bool TryConvertToEnumAndAssignValue(Type type, string input, out object value)Parameters
Returns
- bool
-
True if the conversion was successful, false otherwise.
TryConvertToUri(string, out object)
Describes whether try convert to uri
internal static bool TryConvertToUri(string inputString, out object result)Parameters
Returns
- bool
-
The is uri created
TryConvertTokenToEnumValue(Type, string[], Array, string, out object)
Describes whether try convert token to enum value
internal static bool TryConvertTokenToEnumValue(Type type, string[] names, Array values, string token, out object tokenValue)Parameters
typeType-
The type
namesstring[]-
The names
valuesArray-
The values
tokenstring-
The token
tokenValueobject-
The token value
Returns
- bool
-
The bool
TryGetEnumNamesAndValues(Type, out string[], out Array)
Describes whether try get enum names and values
internal static bool TryGetEnumNamesAndValues(Type type, out string[] names, out Array values)Parameters
Returns
- bool
-
The bool
TryHandleDigitOrSignStart(Type, string, out object)
Describes whether try handle digit or sign start
internal static bool TryHandleDigitOrSignStart(Type type, string input, out object value)Parameters
Returns
- bool
-
The bool
TryMatchNames(string[], Array, string, out object)
Describes whether try match names
internal static bool TryMatchNames(string[] names, Array values, string input, out object value)Parameters
Returns
- bool
-
The bool
TryMatchValues(Array, string, out object)
Describes whether try match values
internal static bool TryMatchValues(Array values, string input, out object value)Parameters
Returns
- bool
-
The bool
TryParseHexadecimal(string, Type, out object)
Describes whether try parse hexadecimal
internal static bool TryParseHexadecimal(string input, Type type, out object value)Parameters
Returns
- bool
-
The bool
TryParseToken(string, Type, string[], Array, out object)
Describes whether try parse token
internal static bool TryParseToken(string token, Type type, string[] names, Array values, out object tokenValue)Parameters
tokenstring-
The token
typeType-
The type
namesstring[]-
The names
valuesArray-
The values
tokenValueobject-
The token value
Returns
- bool
-
The bool
TryParseTokenValues(string[], Type, string[], Array, out object)
Describes whether try parse token values
internal static bool TryParseTokenValues(string[] tokens, Type type, string[] names, Array values, out object value)Parameters
tokensstring[]-
The tokens
typeType-
The type
namesstring[]-
The names
valuesArray-
The values
valueobject-
The value
Returns
- bool
-
The bool
TryParseTokens(string, Type, string[], Array, out object)
Describes whether try parse tokens
internal static bool TryParseTokens(string input, Type type, string[] names, Array values, out object value)Parameters
inputstring-
The input
typeType-
The type
namesstring[]-
The names
valuesArray-
The values
valueobject-
The value
Returns
- bool
-
The bool
TryStringToEnum(Type, string[], Array, string, out object)
Tries to convert a string to an enum value.
internal static bool TryStringToEnum(Type type, string[] names, Array values, string input, out object value)Parameters
typeType-
The type of the enum.
namesstring[]-
The names of the enum values.
valuesArray-
The values of the enum.
inputstring-
The input string to convert.
valueobject-
The converted enum value if the conversion is successful, otherwise the default value of the enum type.
Returns
- bool
-
True if the conversion is successful, otherwise false.