Table of Contents

Class StringDecoratorExtensions

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Extension methods for the String class hidden behind the IDecorator<T> interface.

public static class StringDecoratorExtensions
Inheritance
StringDecoratorExtensions

Methods

ContainsAny(IDecorator<String>, Char, StringComparison)

Returns a value indicating whether the specified find occurs within the enclosed String of the specified decorator.

public static bool ContainsAny(this IDecorator<string> decorator, char find, StringComparison comparison = StringComparison.OrdinalIgnoreCase)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

find Char

The Char to search within enclosed String of the specified decorator.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.

Returns

Boolean

true if the find parameter occurs within the enclosed String of the specified decorator; otherwise, false.

Exceptions

ArgumentNullException

decorator is null -or- find is null.

ContainsAny(IDecorator<String>, StringComparison, Char[])

Returns a value indicating whether the specified values occurs within the enclosed String of the specified decorator object.

public static bool ContainsAny(this IDecorator<string> decorator, StringComparison comparison, params char[] values)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison.

values Char[]

The Char sequence to search within the enclosed String of the specified decorator.

Returns

Boolean

true if the values parameter occurs within the enclosed String of the specified decorator; otherwise, false.

Exceptions

ArgumentNullException

decorator is null -or- values is null.

Difference(IDecorator<String>, String)

Returns the set difference between second and the enclosed String of the specified decorator or Empty if no difference.

public static string Difference(this IDecorator<string> decorator, string second)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

second String

The value to compare with the enclosed String of the specified decorator.

Returns

String

A String that contains the set difference between second and the enclosed String of the specified decorator or Empty if no difference.

StartsWith(IDecorator<String>, IEnumerable<String>)

Determines whether the beginning of the enclosed String of the specified decorator matches at least one string in the specified sequence of strings.

public static bool StartsWith(this IDecorator<string> decorator, IEnumerable<string> strings)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

strings IEnumerable<String>

A sequence of String values to match against.

Returns

Boolean

true if at least one value matches the beginning of the enclosed String of the specified decorator; otherwise, false.

Remarks

This match is performed by using a default value of OrdinalIgnoreCase.

StartsWith(IDecorator<String>, String[])

Determines whether the beginning of the enclosed String of the specified decorator matches at least one string in the specified sequence of strings.

public static bool StartsWith(this IDecorator<string> decorator, params string[] strings)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

strings String[]

A sequence of String values to match against.

Returns

Boolean

true if at least one value matches the beginning of the enclosed String of the specified decorator; otherwise, false.

Remarks

This match is performed by using a default value of OrdinalIgnoreCase.

StartsWith(IDecorator<String>, StringComparison, IEnumerable<String>)

Determines whether the beginning of the enclosed String of the specified decorator matches at least one string in the specified sequence of strings.

public static bool StartsWith(this IDecorator<string> decorator, StringComparison comparison, IEnumerable<string> strings)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison.

strings IEnumerable<String>

A sequence of String values to match against.

Returns

Boolean

true if at least one value matches the beginning of the enclosed String of the specified decorator; otherwise, false.

StartsWith(IDecorator<String>, StringComparison, String[])

Determines whether the beginning of the enclosed String of the specified decorator matches at least one string in the specified sequence of strings.

public static bool StartsWith(this IDecorator<string> decorator, StringComparison comparison, params string[] strings)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

comparison StringComparison

One of the enumeration values that specifies the rules to use in the comparison.

strings String[]

A sequence of String values to match against.

Returns

Boolean

true if at least one value matches the beginning of this string; otherwise, false.

Remarks

This match is performed by using a default value of OrdinalIgnoreCase.

ToAsciiEncodedString(IDecorator<String>, Action<EncodingOptions>)

Encodes all the characters in the enclosed String of the specified decorator to its ASCII encoded variant.

public static string ToAsciiEncodedString(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

setup Action<EncodingOptions>

The EncodingOptions which may be configured.

Returns

String

A String variant of the enclosed String of the specified decorator that is ASCII encoded.

Exceptions

ArgumentNullException

decorator cannot be null.

ToByteArray(IDecorator<String>, Action<EncodingOptions>)

Converts the enclosed String of the specified decorator to its equivalent byte[] representation.

public static byte[] ToByteArray(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

setup Action<EncodingOptions>

The EncodingOptions which may be configured.

Returns

Byte[]

A byte[] containing the result of the enclosed String of the specified decorator.

Exceptions

ArgumentNullException

decorator cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

ToCasing(IDecorator<String>, CasingMethod)

Converts the enclosed String of the specified decorator to either lowercase, UPPERCASE, Title Case or unaltered.

public static string ToCasing(this IDecorator<string> decorator, CasingMethod method = CasingMethod.Default)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

method CasingMethod

The method to use in the conversion.

Returns

String

A String that corresponds to the enclosed String of the specified decorator with the applied conversion method.

Remarks

Uses InvariantCulture for the conversion.

Exceptions

ArgumentNullException

decorator cannot be null.

ToCasing(IDecorator<String>, CasingMethod, CultureInfo)

Converts the enclosed String of the specified decorator to either lowercase, UPPERCASE, Title Case or unaltered using the specified culture.

public static string ToCasing(this IDecorator<string> decorator, CasingMethod method, CultureInfo culture)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

method CasingMethod

The method to use in the conversion.

culture CultureInfo

The culture rules to apply the conversion.

Returns

String

A String that corresponds to the enclosed String of the specified decorator with the applied conversion method.

Exceptions

ArgumentNullException

decorator cannot be null -or- culture cannot be null.

ToEncodedString(IDecorator<String>, Action<FallbackEncodingOptions>)

Encodes all the characters in the enclosed String of the specified decorator to its encoded String variant.

public static string ToEncodedString(this IDecorator<string> decorator, Action<FallbackEncodingOptions> setup = null)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

setup Action<FallbackEncodingOptions>

The FallbackEncodingOptions which may be configured.

Returns

String

A String variant of the enclosed String of the specified decorator that is encoded with TargetEncoding.

Remarks

The inspiration for this method was retrieved @ SO: https://stackoverflow.com/a/135473/175073.

Exceptions

ArgumentNullException

decorator cannot be null.

ToStream(IDecorator<String>, Action<EncodingOptions>)

Converts the enclosed String of the specified decorator to a Stream.

public static Stream ToStream(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

setup Action<EncodingOptions>

The EncodingOptions which may be configured.

Returns

Stream

A Stream containing the result of the enclosed String of the specified decorator.

Remarks

Exceptions

ArgumentNullException

decorator cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

ToUri(IDecorator<String>, UriKind)

Converts the enclosed String of the specified decorator to its equivalent Uri representation.

public static Uri ToUri(this IDecorator<string> decorator, UriKind uriKind = UriKind.Absolute)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

uriKind UriKind

Specifies whether the URI string is a relative URI, absolute URI, or is indeterminate.

Returns

Uri

A Uri that corresponds to the enclosed String of the specified decorator and uriKind.

Exceptions

ArgumentNullException

decorator cannot be null.

ArgumentNullException

The enclosed String of the specified decorator cannot be null.

ArgumentException

The enclosed String of the specified decorator cannot be empty or consist only of white-space characters.

See Also