Show / Hide Table of Contents

Class StringDecoratorExtensions

Extension methods for the String class tailored to adhere the decorator pattern.

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

Methods

| Improve this Doc View Source

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.

Declaration
public static bool StartsWith(this IDecorator<string> decorator, IEnumerable<string> strings)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

IEnumerable<String> strings

A sequence of String values to match against.

Returns
Type Description
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.

| Improve this Doc View Source

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.

Declaration
public static bool StartsWith(this IDecorator<string> decorator, params string[] strings)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

String[] strings

A sequence of String values to match against.

Returns
Type Description
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.

| Improve this Doc View Source

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.

Declaration
public static bool StartsWith(this IDecorator<string> decorator, StringComparison comparison, IEnumerable<string> strings)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

StringComparison comparison

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

IEnumerable<String> strings

A sequence of String values to match against.

Returns
Type Description
Boolean

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

| Improve this Doc View Source

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.

Declaration
public static bool StartsWith(this IDecorator<string> decorator, StringComparison comparison, params string[] strings)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

StringComparison comparison

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

String[] strings

A sequence of String values to match against.

Returns
Type Description
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.

| Improve this Doc View Source

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

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

Declaration
public static string ToAsciiEncodedString(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

Action<EncodingOptions> setup

The EncodingOptions which may be configured.

Returns
Type Description
String

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

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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

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

Declaration
public static byte[] ToByteArray(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

Action<EncodingOptions> setup

The EncodingOptions which may be configured.

Returns
Type Description
Byte[]

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

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

| Improve this Doc View Source

ToCasing(IDecorator<String>, CasingMethod)

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

Declaration
public static string ToCasing(this IDecorator<string> decorator, CasingMethod method = CasingMethod.Default)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

CasingMethod method

The method to use in the conversion.

Returns
Type Description
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
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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.

Declaration
public static string ToCasing(this IDecorator<string> decorator, CasingMethod method, CultureInfo culture)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

CasingMethod method

The method to use in the conversion.

CultureInfo culture

The culture rules to apply the conversion.

Returns
Type Description
String

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

Exceptions
Type Condition
ArgumentNullException

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

| Improve this Doc View Source

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

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

Declaration
public static string ToEncodedString(this IDecorator<string> decorator, Action<FallbackEncodingOptions> setup = null)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

Action<FallbackEncodingOptions> setup

The FallbackEncodingOptions which may be configured.

Returns
Type Description
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
Type Condition
ArgumentNullException

decorator cannot be null.

| Improve this Doc View Source

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

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

Declaration
public static Stream ToStream(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

Action<EncodingOptions> setup

The EncodingOptions which may be configured.

Returns
Type Description
Stream

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

Remarks

IEncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

| Improve this Doc View Source

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

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

Declaration
public static Task<Stream> ToStreamAsync(this IDecorator<string> decorator, Action<AsyncEncodingOptions> setup = null)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

Action<AsyncEncodingOptions> setup

The AsyncEncodingOptions which may be configured.

Returns
Type Description
Task<Stream>

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

Remarks

IEncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.

Exceptions
Type Condition
ArgumentNullException

decorator cannot be null.

InvalidEnumArgumentException

setup was initialized with an invalid Preamble.

| Improve this Doc View Source

ToUri(IDecorator<String>, UriKind)

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

Declaration
public static Uri ToUri(this IDecorator<string> decorator, UriKind uriKind = UriKind.Absolute)
Parameters
Type Name Description
IDecorator<String> decorator

The IDecorator<T> to extend.

UriKind uriKind

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

Returns
Type Description
Uri

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

Exceptions
Type Condition
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

IDecorator<T>
Decorator<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright 2008-2022 Geekle. All rights reserved. Code with passion and love; deploy with confidence. 👨‍💻️🔥❤️🚀😎
Generated by DocFX