Table of Contents

Class StringDecoratorExtensions

Namespace
Cuemon
Assembly
Cuemon.Core.dll

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

public static class StringDecoratorExtensions
Inheritance
Object
StringDecoratorExtensions

Methods

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

Determines whether the beginning of the enclosed System.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 System.String values to match against.

Returns

Boolean

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

Remarks

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

StartsWith(IDecorator<String>, String[])

Determines whether the beginning of the enclosed System.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 System.String values to match against.

Returns

Boolean

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

Remarks

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

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

Determines whether the beginning of the enclosed System.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 System.String values to match against.

Returns

Boolean

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

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

Determines whether the beginning of the enclosed System.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 System.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 System.StringComparison.OrdinalIgnoreCase.

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

Encodes all the characters in the enclosed System.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 System.String variant of the enclosed System.String of the specified decorator that is ASCII encoded.

Exceptions

System.ArgumentNullException

decorator cannot be null.

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

Converts the enclosed System.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 System.String of the specified decorator.

Exceptions

System.ArgumentNullException

decorator cannot be null.

System.ComponentModel.InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

ToCasing(IDecorator<String>, CasingMethod)

Converts the enclosed System.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 System.String that corresponds to the enclosed System.String of the specified decorator with the applied conversion method.

Remarks

Uses System.Globalization.CultureInfo.InvariantCulture for the conversion.

Exceptions

System.ArgumentNullException

decorator cannot be null.

ToCasing(IDecorator<String>, CasingMethod, CultureInfo)

Converts the enclosed System.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 System.String that corresponds to the enclosed System.String of the specified decorator with the applied conversion method.

Exceptions

System.ArgumentNullException

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

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

Encodes all the characters in the enclosed System.String of the specified decorator to its encoded System.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 System.String variant of the enclosed System.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

System.ArgumentNullException

decorator cannot be null.

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

Converts the enclosed System.String of the specified decorator to a System.IO.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 System.IO.Stream containing the result of the enclosed System.String of the specified decorator.

Remarks

Exceptions

System.ArgumentNullException

decorator cannot be null.

System.ComponentModel.InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

ToStreamAsync(IDecorator<String>, Action<AsyncEncodingOptions>)

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

public static Task<Stream> ToStreamAsync(this IDecorator<string> decorator, Action<AsyncEncodingOptions> setup = null)

Parameters

decorator IDecorator<String>

The IDecorator<T> to extend.

setup Action<AsyncEncodingOptions>

The AsyncEncodingOptions which may be configured.

Returns

Task<Stream>

A task that represents the asynchronous operation. The task result contains a System.IO.Stream containing the result of the enclosed System.String of the specified decorator.

Remarks

Exceptions

System.ArgumentNullException

decorator cannot be null.

System.ComponentModel.InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

ToUri(IDecorator<String>, UriKind)

Converts the enclosed System.String of the specified decorator to its equivalent System.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 System.Uri that corresponds to the enclosed System.String of the specified decorator and uriKind.

Exceptions

System.ArgumentNullException

decorator cannot be null.

System.ArgumentNullException

The enclosed System.String of the specified decorator cannot be null.

ArgumentException

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

See Also