Show / Hide Table of Contents

    Class Converter

    This utility class is designed to make generic conversions easier to work with.

    Inheritance
    System.Object
    Converter
    Namespace: Cuemon
    Assembly: Cuemon.Core.dll
    Syntax
    public static class Converter

    Methods

    | Improve this Doc

    FromObject<TResult>(Object)

    Attempts to convert the specified value to a given type. If the conversion is not possible the result is set to default(TResult).

    Declaration
    public static TResult FromObject<TResult>(object value)
    Parameters
    Type Name Description
    System.Object value

    The object to convert the underlying type.

    Returns
    Type Description
    TResult

    The value converted to the specified TResult.

    Type Parameters
    Name Description
    TResult

    The type of the result.

    Remarks

    This method first checks if value is compatible with TResult; if not compatible the method continues with ChangeType(Object, Type, IFormatProvider) for the operation.

    | Improve this Doc

    FromObject<TResult>(Object, TResult)

    Attempts to convert the specified value to a given type. If the conversion is not possible the result is set to resultOnConversionNotPossible.

    Declaration
    public static TResult FromObject<TResult>(object value, TResult resultOnConversionNotPossible)
    Parameters
    Type Name Description
    System.Object value

    The object to convert the underlying type.

    TResult resultOnConversionNotPossible

    The value to return if the conversion is not possible.

    Returns
    Type Description
    TResult

    The value converted to the specified TResult.

    Type Parameters
    Name Description
    TResult

    The type of the result.

    Remarks

    This method first checks if value is compatible with TResult; if not compatible the method continues with ChangeType(Object, Type, IFormatProvider) for the operation.

    | Improve this Doc

    FromObject<TResult>(Object, TResult, IFormatProvider)

    Attempts to convert the specified value to a given type. If the conversion is not possible the result is set to resultOnConversionNotPossible.

    Declaration
    public static TResult FromObject<TResult>(object value, TResult resultOnConversionNotPossible, IFormatProvider provider)
    Parameters
    Type Name Description
    System.Object value

    The object to convert the underlying type.

    TResult resultOnConversionNotPossible

    The value to return if the conversion is not possible.

    System.IFormatProvider provider

    An object that supplies culture-specific formatting information.

    Returns
    Type Description
    TResult

    The value converted to the specified TResult.

    Type Parameters
    Name Description
    TResult

    The type of the result.

    Remarks

    This method first checks if value is compatible with TResult; if not compatible the method continues with ChangeType(Object, Type, IFormatProvider) for the operation.

    | Improve this Doc

    FromString<T>(String)

    Converts the specified string to its T equivalent.

    Declaration
    public static T FromString<T>(string value)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    Returns
    Type Description
    T

    An object that is equivalent to T contained in value.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    Exceptions
    Type Condition
    System.ArgumentException

    Invalid value for T specified.

    System.NotSupportedException

    The conversion cannot be performed.

    | Improve this Doc

    FromString<T>(String, CultureInfo)

    Converts the specified string to its T equivalent using the specified culture information.

    Declaration
    public static T FromString<T>(string value, CultureInfo culture)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    System.Globalization.CultureInfo culture

    The culture-specific formatting information about value.

    Returns
    Type Description
    T

    An object that is equivalent to T contained in value, as specified by culture.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    Exceptions
    Type Condition
    System.ArgumentException

    Invalid value for T specified.

    System.NotSupportedException

    The conversion cannot be performed.

    | Improve this Doc

    FromString<T>(String, CultureInfo, ITypeDescriptorContext)

    Converts the specified string to its T equivalent using the specified context and culture information.

    Declaration
    public static T FromString<T>(string value, CultureInfo culture, ITypeDescriptorContext context)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    System.Globalization.CultureInfo culture

    The culture-specific formatting information about value.

    System.ComponentModel.ITypeDescriptorContext context

    The type-specific formatting information about value.

    Returns
    Type Description
    T

    An object that is equivalent to T contained in value, as specified by culture and context.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    Exceptions
    Type Condition
    System.ArgumentException

    Invalid value for T specified.

    System.NotSupportedException

    The conversion cannot be performed.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, T5, T6, T7, T8, TResult>(TSource, Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, TResult>, T1, T2, T3, T4, T5, T6, T7, T8)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, T5, T6, T7, T8, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    T5 arg5

    The fifth parameter of the function delegate converter.

    T6 arg6

    The sixth parameter of the function delegate converter.

    T7 arg7

    The seventh parameter of the function delegate converter.

    T8 arg8

    The eighth parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    T5

    The type of the fifth parameter of the function delegate converter.

    T6

    The type of the sixth parameter of the function delegate converter.

    T7

    The type of the seventh parameter of the function delegate converter.

    T8

    The type of the eighth parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(TSource, Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>, T1, T2, T3, T4, T5, T6, T7, T8, T9)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    T5 arg5

    The fifth parameter of the function delegate converter.

    T6 arg6

    The sixth parameter of the function delegate converter.

    T7 arg7

    The seventh parameter of the function delegate converter.

    T8 arg8

    The eighth parameter of the function delegate converter.

    T9 arg9

    The ninth parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    T5

    The type of the fifth parameter of the function delegate converter.

    T6

    The type of the sixth parameter of the function delegate converter.

    T7

    The type of the seventh parameter of the function delegate converter.

    T8

    The type of the eighth parameter of the function delegate converter.

    T9

    The type of the ninth parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, TResult>(TSource, Func<TSource, TResult>)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, TResult>(TSource source, Func<TSource, TResult> converter)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T, TResult>(TSource, Func<TSource, T, TResult>, T)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T, TResult>(TSource source, Func<TSource, T, TResult> converter, T arg)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T arg

    The parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T

    The type of the parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, TResult>(TSource, Func<TSource, T1, T2, TResult>, T1, T2)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, TResult>(TSource source, Func<TSource, T1, T2, TResult> converter, T1 arg1, T2 arg2)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, TResult>(TSource, Func<TSource, T1, T2, T3, TResult>, T1, T2, T3)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, TResult>(TSource source, Func<TSource, T1, T2, T3, TResult> converter, T1 arg1, T2 arg2, T3 arg3)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, TResult>(TSource, Func<TSource, T1, T2, T3, T4, TResult>, T1, T2, T3, T4)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, T5, TResult>(TSource, Func<TSource, T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, T5, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, T5, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, T5, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    T5 arg5

    The fifth parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    T5

    The type of the fifth parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, T5, T6, TResult>(TSource, Func<TSource, T1, T2, T3, T4, T5, T6, TResult>, T1, T2, T3, T4, T5, T6)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, T5, T6, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, T5, T6, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, T5, T6, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    T5 arg5

    The fifth parameter of the function delegate converter.

    T6 arg6

    The sixth parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    T5

    The type of the fifth parameter of the function delegate converter.

    T6

    The type of the sixth parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    Parse<TSource, T1, T2, T3, T4, T5, T6, T7, TResult>(TSource, Func<TSource, T1, T2, T3, T4, T5, T6, T7, TResult>, T1, T2, T3, T4, T5, T6, T7)

    Converts the specified source to a TResult representation using the specified converter.

    Declaration
    public static TResult Parse<TSource, T1, T2, T3, T4, T5, T6, T7, TResult>(TSource source, Func<TSource, T1, T2, T3, T4, T5, T6, T7, TResult> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
    Parameters
    Type Name Description
    TSource source

    The source to parse and convert using the function delegate converter.

    System.Func<TSource, T1, T2, T3, T4, T5, T6, T7, TResult> converter

    The function delegate that converts TSource to a TResult representation.

    T1 arg1

    The first parameter of the function delegate converter.

    T2 arg2

    The second parameter of the function delegate converter.

    T3 arg3

    The third parameter of the function delegate converter.

    T4 arg4

    The fourth parameter of the function delegate converter.

    T5 arg5

    The fifth parameter of the function delegate converter.

    T6 arg6

    The sixth parameter of the function delegate converter.

    T7 arg7

    The seventh parameter of the function delegate converter.

    Returns
    Type Description
    TResult

    A TResult that is equivalent to the TSource contained in source.

    Type Parameters
    Name Description
    TSource

    The type of the source to convert.

    T1

    The type of the first parameter of the function delegate converter.

    T2

    The type of the second parameter of the function delegate converter.

    T3

    The type of the third parameter of the function delegate converter.

    T4

    The type of the fourth parameter of the function delegate converter.

    T5

    The type of the fifth parameter of the function delegate converter.

    T6

    The type of the sixth parameter of the function delegate converter.

    T7

    The type of the seventh parameter of the function delegate converter.

    TResult

    The type of the converted result.

    Exceptions
    Type Condition
    System.ArgumentNullException

    converter is null.

    | Improve this Doc

    TryFromString<T>(String, out T)

    Converts the specified string to its T equivalent.

    Declaration
    public static bool TryFromString<T>(string value, out T result)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    T result

    When this method returns, contains the equivalent to T of value, or default(T) if an exception is thrown.

    Returns
    Type Description
    System.Boolean

    true if the value parameter was successfully converted; otherwise false.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    | Improve this Doc

    TryFromString<T>(String, CultureInfo, out T)

    Converts the specified string to its T equivalent using the specified culture information.

    Declaration
    public static bool TryFromString<T>(string value, CultureInfo culture, out T result)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    System.Globalization.CultureInfo culture

    The culture-specific formatting information about value.

    T result

    When this method returns, contains the equivalent to T of value, as specified by culture, or default(T) if an exception is thrown.

    Returns
    Type Description
    System.Boolean

    true if the value parameter was successfully converted; otherwise false.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    | Improve this Doc

    TryFromString<T>(String, CultureInfo, ITypeDescriptorContext, out T)

    Converts the specified string to its T equivalent using the specified context and culture information.

    Declaration
    public static bool TryFromString<T>(string value, CultureInfo culture, ITypeDescriptorContext context, out T result)
    Parameters
    Type Name Description
    System.String value

    The string value to convert.

    System.Globalization.CultureInfo culture

    The culture-specific formatting information about value.

    System.ComponentModel.ITypeDescriptorContext context

    The type-specific formatting information about value.

    T result

    When this method returns, contains the equivalent to T of value, as specified by culture and context, or default(T) if an exception is thrown.

    Returns
    Type Description
    System.Boolean

    true if the value parameter was successfully converted; otherwise false.

    Type Parameters
    Name Description
    T

    The type of the expected return value after conversion.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX