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
decoratorIDecorator<string>The IDecorator<T> to extend.
findcharThe char to search within enclosed string of the specified
decorator.comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison. Default is OrdinalIgnoreCase.
Returns
- bool
trueif thefindparameter occurs within the enclosed string of the specifieddecorator; otherwise,false.
Exceptions
- ArgumentNullException
decoratoris null -or-findis null.
ContainsAny(IDecorator<string>, StringComparison, params 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
decoratorIDecorator<string>The IDecorator<T> to extend.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison.
valueschar[]The char sequence to search within the enclosed string of the specified
decorator.
Returns
- bool
trueif thevaluesparameter occurs within the enclosed string of the specifieddecorator; otherwise,false.
Exceptions
- ArgumentNullException
decoratoris null -or-valuesis 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
decoratorIDecorator<string>The IDecorator<T> to extend.
secondstringThe value to compare with the enclosed string of the specified
decorator.
Returns
- string
A string that contains the set difference between
secondand the enclosed string of the specifieddecoratoror 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
decoratorIDecorator<string>The IDecorator<T> to extend.
stringsIEnumerable<string>A sequence of string values to match against.
Returns
- bool
trueif at least one value matches the beginning of the enclosed string of the specifieddecorator; 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
decoratorIDecorator<string>The IDecorator<T> to extend.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison.
stringsIEnumerable<string>A sequence of string values to match against.
Returns
- bool
trueif at least one value matches the beginning of the enclosed string of the specifieddecorator; otherwise,false.
StartsWith(IDecorator<string>, StringComparison, params 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
decoratorIDecorator<string>The IDecorator<T> to extend.
comparisonStringComparisonOne of the enumeration values that specifies the rules to use in the comparison.
stringsstring[]A sequence of string values to match against.
Returns
- bool
trueif at least one value matches the beginning of this string; otherwise,false.
Remarks
This match is performed by using a default value of OrdinalIgnoreCase.
StartsWith(IDecorator<string>, params 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
decoratorIDecorator<string>The IDecorator<T> to extend.
stringsstring[]A sequence of string values to match against.
Returns
- bool
trueif at least one value matches the beginning of the enclosed string of the specifieddecorator; 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
decoratorIDecorator<string>The IDecorator<T> to extend.
setupAction<EncodingOptions>The EncodingOptions which may be configured.
Returns
Exceptions
- ArgumentNullException
decoratorcannot 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
decoratorIDecorator<string>The IDecorator<T> to extend.
setupAction<EncodingOptions>The EncodingOptions which may be configured.
Returns
Exceptions
- ArgumentNullException
decoratorcannot be null.- InvalidEnumArgumentException
setupwas 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
decoratorIDecorator<string>The IDecorator<T> to extend.
methodCasingMethodThe method to use in the conversion.
Returns
- string
A string that corresponds to the enclosed string of the specified
decoratorwith the applied conversionmethod.
Remarks
Uses InvariantCulture for the conversion.
Exceptions
- ArgumentNullException
decoratorcannot 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
decoratorIDecorator<string>The IDecorator<T> to extend.
methodCasingMethodThe method to use in the conversion.
cultureCultureInfoThe culture rules to apply the conversion.
Returns
- string
A string that corresponds to the enclosed string of the specified
decoratorwith the applied conversionmethod.
Exceptions
- ArgumentNullException
decoratorcannot be null -or-culturecannot 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
decoratorIDecorator<string>The IDecorator<T> to extend.
setupAction<FallbackEncodingOptions>The FallbackEncodingOptions which may be configured.
Returns
- string
A string variant of the enclosed string of the specified
decoratorthat is encoded with TargetEncoding.
Remarks
The inspiration for this method was retrieved @ SO: https://stackoverflow.com/a/135473/175073.
Exceptions
- ArgumentNullException
decoratorcannot be null.
ToStream(IDecorator<string>, Action<EncodingOptions>)
public static Stream ToStream(this IDecorator<string> decorator, Action<EncodingOptions> setup = null)
Parameters
decoratorIDecorator<string>The IDecorator<T> to extend.
setupAction<EncodingOptions>The EncodingOptions which may be configured.
Returns
Remarks
IEncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
Exceptions
- ArgumentNullException
decoratorcannot be null.- InvalidEnumArgumentException
setupwas initialized with an invalid Preamble.
ToUri(IDecorator<string>, UriKind)
public static Uri ToUri(this IDecorator<string> decorator, UriKind uriKind = UriKind.Absolute)
Parameters
decoratorIDecorator<string>The IDecorator<T> to extend.
uriKindUriKindSpecifies whether the URI string is a relative URI, absolute URI, or is indeterminate.
Returns
Exceptions
- ArgumentNullException
decoratorcannot be null.- ArgumentNullException
The enclosed string of the specified
decoratorcannot be null.- ArgumentException
The enclosed string of the specified
decoratorcannot be empty or consist only of white-space characters.