Class StringConverterExtensions
This is an extension implementation of the StringConverter class.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class StringConverterExtensions
Methods
| Improve this DocFromChars(IEnumerable<Char>)
Converts the specified value to its equivalent System.String representation.
Declaration
public static string FromChars(this IEnumerable<char> value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Char> | value | The System.Char sequence to convert. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String equivalent to the specified |
FromHexadecimal(String, Action<EncodingOptions>)
Converts the specified hexadecimal value to its equivalent System.String representation.
Declaration
public static string FromHexadecimal(this string value, Action<EncodingOptions> setup = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The hexadecimal string to be converted. |
| System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String representation of the hexadecimal characters in |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToBinary(Byte[])
Converts the specified value to its equivalent binary representation.
Declaration
public static string ToBinary(this byte[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | value | The byte array to be converted. |
Returns
| Type | Description |
|---|---|
| System.String | A binary System.String representation of the elements in |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ToDelimitedString<TSource>(IEnumerable<TSource>)
Converts the specified source to a string of comma delimited values.
Declaration
public static string ToDelimitedString<TSource>(this IEnumerable<TSource> source)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of comma delimited values. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the |
ToDelimitedString<TSource>(IEnumerable<TSource>, String)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource>(this IEnumerable<TSource> source, string delimiter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A sequence of elements to be converted. |
| System.String | delimiter | The delimiter specification. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
ToDelimitedString<TSource>(IEnumerable<TSource>, String, Func<TSource, String>)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource>(this IEnumerable<TSource> source, string delimiter, Func<TSource, string> converter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A sequence of elements to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, System.String> | converter | The function delegate that converts |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
ToDelimitedString<TSource>(IEnumerable<TSource>, String, String)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource>(this IEnumerable<TSource> source, string delimiter, string format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A sequence of elements to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
ToDelimitedString<TSource>(IEnumerable<TSource>, String, String, Func<TSource, String>)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, string> converter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A sequence of elements to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, System.String> | converter | The function delegate that converts |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
ToDelimitedString<TSource, T>(IEnumerable<TSource>, String, Func<TSource, T, String>, T)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T>(this IEnumerable<TSource> source, string delimiter, Func<TSource, T, string> converter, T arg)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, T, System.String> | converter | The function delegate that converts |
| T | arg | The parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T | The type of the parameter of the function delegate |
ToDelimitedString<TSource, T>(IEnumerable<TSource>, String, String, Func<TSource, T, String>, T)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, T, string> converter, T arg)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, T, System.String> | converter | The function delegate that converts |
| T | arg | The parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T | The type of the parameter of the function delegate |
ToDelimitedString<TSource, T1, T2>(IEnumerable<TSource>, String, Func<TSource, T1, T2, String>, T1, T2)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2>(this IEnumerable<TSource> source, string delimiter, Func<TSource, T1, T2, string> converter, T1 arg1, T2 arg2)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, T1, T2, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
ToDelimitedString<TSource, T1, T2>(IEnumerable<TSource>, String, String, Func<TSource, T1, T2, String>, T1, T2)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, T1, T2, string> converter, T1 arg1, T2 arg2)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, T1, T2, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3>(IEnumerable<TSource>, String, Func<TSource, T1, T2, T3, String>, T1, T2, T3)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3>(this IEnumerable<TSource> source, string delimiter, Func<TSource, T1, T2, T3, string> converter, T1 arg1, T2 arg2, T3 arg3)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, T1, T2, T3, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3>(IEnumerable<TSource>, String, String, Func<TSource, T1, T2, T3, String>, T1, T2, T3)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, T1, T2, T3, string> converter, T1 arg1, T2 arg2, T3 arg3)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, T1, T2, T3, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3, T4>(IEnumerable<TSource>, String, Func<TSource, T1, T2, T3, T4, String>, T1, T2, T3, T4)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3, T4>(this IEnumerable<TSource> source, string delimiter, Func<TSource, T1, T2, T3, T4, string> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, T1, T2, T3, T4, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3, T4>(IEnumerable<TSource>, String, String, Func<TSource, T1, T2, T3, T4, String>, T1, T2, T3, T4)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3, T4>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, T1, T2, T3, T4, string> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, T1, T2, T3, T4, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3, T4, T5>(IEnumerable<TSource>, String, Func<TSource, T1, T2, T3, T4, T5, String>, T1, T2, T3, T4, T5)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3, T4, T5>(this IEnumerable<TSource> source, string delimiter, Func<TSource, T1, T2, T3, T4, T5, string> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.Func<TSource, T1, T2, T3, T4, T5, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| T5 | arg5 | The fifth parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
| T5 | The type of the fifth parameter of the function delegate |
ToDelimitedString<TSource, T1, T2, T3, T4, T5>(IEnumerable<TSource>, String, String, Func<TSource, T1, T2, T3, T4, T5, String>, T1, T2, T3, T4, T5)
Converts the specified source to a string of delimiter delimited values.
Declaration
public static string ToDelimitedString<TSource, T1, T2, T3, T4, T5>(this IEnumerable<TSource> source, string delimiter, string format, Func<TSource, T1, T2, T3, T4, T5, string> converter, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | source | A collection of values to be converted. |
| System.String | delimiter | The delimiter specification. |
| System.String | format | The desired format of the converted values. |
| System.Func<TSource, T1, T2, T3, T4, T5, System.String> | converter | The function delegate that converts |
| T1 | arg1 | The first parameter of the function delegate |
| T2 | arg2 | The second parameter of the function delegate |
| T3 | arg3 | The third parameter of the function delegate |
| T4 | arg4 | The fourth parameter of the function delegate |
| T5 | arg5 | The fifth parameter of the function delegate |
Returns
| Type | Description |
|---|---|
| System.String | A System.String of delimited values from the by parameter specified delimiter. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the sequence to convert. |
| T1 | The type of the first parameter of the function delegate |
| T2 | The type of the second parameter of the function delegate |
| T3 | The type of the third parameter of the function delegate |
| T4 | The type of the fourth parameter of the function delegate |
| T5 | The type of the fifth parameter of the function delegate |
ToEncodedString(Byte[], Action<EncodingOptions>)
Converts the specified value to a string using the provided preferred encoding.
Declaration
public static string ToEncodedString(this byte[] value, Action<EncodingOptions> setup = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | value | The byte array to be converted. |
| System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String containing the results of decoding the specified sequence of bytes. |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToEncodedString(Exception, Boolean)
Renders the exception to a human readable System.String.
Declaration
public static string ToEncodedString(this Exception exception, bool includeStackTrace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Exception | exception | The System.Exception to render human readable. |
| System.Boolean | includeStackTrace | if set to |
Returns
| Type | Description |
|---|---|
| System.String | A human readable System.String variant of the specified |
ToEncodedString(Exception, Boolean, Encoding)
Renders the exception to a human readable System.String.
Declaration
public static string ToEncodedString(this Exception exception, bool includeStackTrace, Encoding encoding)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Exception | exception | The System.Exception to render human readable. |
| System.Boolean | includeStackTrace | if set to |
| System.Text.Encoding | encoding | The encoding to use when rendering the |
Returns
| Type | Description |
|---|---|
| System.String | A human readable System.String variant of the specified |
ToEncodedString(Stream, Action<EncodingOptions>)
Converts the specified value to a string using the provided preferred encoding.
Declaration
public static string ToEncodedString(this Stream value, Action<EncodingOptions> setup = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | value | The System.IO.Stream to be converted. |
| System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String containing the decoded result of the specified |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToEncodedString(Stream, Action<EncodingOptions>, Boolean)
Converts the specified value to a string using the provided preferred encoding.
Declaration
public static string ToEncodedString(this Stream value, Action<EncodingOptions> setup, bool leaveStreamOpen)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | value | The System.IO.Stream to be converted. |
| System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
| System.Boolean | leaveStreamOpen | if |
Returns
| Type | Description |
|---|---|
| System.String | A System.String containing the decoded result of the specified |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToEnumerable(IEnumerable<Char>)
Converts the specified value to its equivalent System.String sequence.
Declaration
public static IEnumerable<string> ToEnumerable(this IEnumerable<char> value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Char> | value | The value to convert into a sequence. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | A System.String sequence equivalent to the specified |
ToFriendlyName(Type)
Converts the name of the source with the intend to be understood by humans.
Declaration
public static string ToFriendlyName(this Type source)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | source | The type to sanitize the name from. |
Returns
| Type | Description |
|---|---|
| System.String | A sanitized System.String representation of |
Remarks
Only the simple name of the source is returned, not the fully qualified name.
ToFriendlyName(Type, Boolean)
Converts the name of the source with the intend to be understood by humans.
Declaration
public static string ToFriendlyName(this Type source, bool fullName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | source | The type to sanitize the name from. |
| System.Boolean | fullName | Specify |
Returns
| Type | Description |
|---|---|
| System.String | A sanitized System.String representation of |
ToFriendlyName(Type, Boolean, Boolean)
Converts the name of the source with the intend to be understood by humans.
Declaration
public static string ToFriendlyName(this Type source, bool fullName, bool excludeGenericArguments)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | source | The type to sanitize the name from. |
| System.Boolean | fullName | Specify |
| System.Boolean | excludeGenericArguments | Specify |
Returns
| Type | Description |
|---|---|
| System.String | A sanitized System.String representation of |
ToHexadecimal(Byte[])
Converts the specified value to its equivalent hexadecimal representation.
Declaration
public static string ToHexadecimal(this byte[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | value | The byte array to be converted. |
Returns
| Type | Description |
|---|---|
| System.String | A hexadecimal System.String representation of the elements in |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
ToHexadecimal(String, Action<EncodingOptions>)
Converts the specified value to its equivalent hexadecimal representation.
Declaration
public static string ToHexadecimal(this string value, Action<EncodingOptions> setup = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | The string to be converted. |
| System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
Returns
| Type | Description |
|---|---|
| System.String | A hexadecimal System.String representation of the characters in |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToUrlEncodedBase64(Byte[])
Encodes a byte array into its equivalent string representation using base 64 digits, which is usable for transmission on the URL.
Declaration
public static string ToUrlEncodedBase64(this byte[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | value | The byte array to encode. |
Returns
| Type | Description |
|---|---|
| System.String | The string containing the encoded token if the byte array length is greater than one; otherwise, an empty string (""). |