C# Класс ClrPlus.Core.Extensions.StringExtensions

Extensions for strings. Whheeee
Показать файл Открыть проект

Открытые методы

Метод Описание
CamelCaseToDashed ( this camelCaseText, char separator = '-' ) : string
Contains ( this text ) : bool
ContainsAllAsWildcards ( this source ) : bool
ContainsAnyAsWildcards ( this source ) : bool
ContainsIgnoreCase ( this source, string value ) : bool

A case insensitive Contains() method.

CreateGuid ( this str ) : System.Guid

Creates a GUID from an MD5 value of the string passed in.

CreatePublicKeyToken ( this publicKey ) : string

Creates the public key token given a public key.. Note: Does this work?

DashedToCamelCase ( this dashedText, char separator = '-' ) : string
DashedToPascalCase ( this dashedText, char separator = '-' ) : string
EmptyAsNull ( this str ) : string
EqualsEx ( this str1, string str2 ) : bool

Checks to see if strings are equal, with empty strings being considered equal to null.

Error ( this formatString ) : void

Errors the specified format string.

FormatWithMacros ( this value, GetMacroValueDelegate getMacroValue, object eachItem = null, GetMacroValueDelegate preprocessValue = null, GetMacroValueDelegate postprocessValue = null ) : string
GetKeyTokenFromFullKey ( this fullKey ) : byte[]

Gets the key token from full key. Does this work?

Gunzip ( this input ) : string

Gunzips the specified input.

GunzipFromBase64 ( this input ) : string

Gunzips from base64.

Gzip ( this input ) : byte[]

Gzips the specified input.

GzipToBase64 ( this input ) : string

Gzips to base64.

HasWildcardMatch ( this source, string value, string ignorePrefix = null ) : bool

Runs IsWildcardMatch on a collection.

HasWildcards ( this input ) : bool

Determines whether the specified input has wildcards.

HtmlDecode ( this s ) : string

decodes an HTML encoded string

HtmlEncode ( this s ) : string

Encodes a string into HTML encoding format, encoding control characters as well.

IfNullOrEmpty ( this text, string defaultText ) : string
Is ( this str ) : bool
IsBoolean ( this text ) : bool

Determines whether the specified text is a boolean (true or false).

IsEmail ( this email ) : bool

Determines whether the specified email is email.

IsFalse ( this text ) : bool

Determines whether the specified text is equal to "false" (ignoring case).

IsMultiline ( this text ) : bool
IsNegative ( this text ) : bool

Determines whether the specified text is equal to some value indicated negative/off/false/no (ignoring case).

IsPositive ( this text ) : bool

Determines whether the specified text equal to some value indicated on/true/enabled (ignoring case).

IsTrue ( this text ) : bool

Determines whether the specified text equal to "true" (ignoring case).

IsWebUri ( this text ) : bool
MD5Hash ( this input ) : string

Calculates the MD5 hash of a string. Additionally all the letters in the hash are in uppercase.

MakeAttractiveFilename ( this input ) : string
MakeSafeDirectoryId ( this input ) : string

Creates a safe directory ID for MSI for a possibly non-safe one.

MakeSafeFileName ( this input ) : string
Match ( this input, string rxExpression ) : Match

Matches the specified input.

MatchIgnoreCase ( this input, string rxExpression ) : Match

Matches a regular expression, ignoring case.

NewIsWildcardMatch ( this text, string wildcardMask, bool isMatchingLocation = false, string currentLocation = null ) : bool

The new implementation of the wildcard matching function. Rules: * means matches anything except slash or backslash ? means match any one character ** means matches anything

OnlyContains ( this str, char characters ) : bool

returns true when the string contains only the characters passed in.

OnlyContains ( this str, string characters ) : bool

returns true when the string contains only the characters in the string passed in .

PositionOfFirstCharacterNotIn ( this str, char characters ) : int

Gets the position of the first character that is not in the collection of characters passed in.

PositionOfFirstCharacterNotIn ( this str, string characters ) : int

Gets the position of the first character that is not in the string passed in.

ProtectBinaryForMachine ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable

encrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit")

ProtectBinaryForUser ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable

encrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit")

ProtectForMachine ( this text, string salt = "CoAppToolkit" ) : IEnumerable

encrypts the given string with the machine key and salt (defaults to "CoAppToolkit")

ProtectForUser ( this text, string salt = "CoAppToolkit" ) : IEnumerable

encrypts the given string with the machine key and salt (defaults to "CoAppToolkit")

Replace ( this s, string oldValue, string newValue, System.StringComparison comparisonType ) : string

Case insensitive version of String.Replace().

StartsWithNumber ( this str ) : bool
ToByteArray ( this text ) : byte[]

Encodes the string as an array of UTF8 bytes.

ToHexString ( this bytes ) : string

Creates a hex representaion of a collection of bytes

ToInt32 ( this str ) : int

coerces a string to an int32, defaults to zero.

ToInt32 ( this str, int defaultValue ) : int

coerces a string to an int32, defaults to zero.

ToSecureString ( this password ) : SecureString
ToUnsecureString ( this securePassword ) : string
ToUri ( this stringUri ) : Uri
ToUtf8String ( this bytes ) : string

Creates a string from a collection of UTF8 bytes

UnprotectBinaryForMachine ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable

decrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit") returns an empty collection of bytes on failure

UnprotectBinaryForUser ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable

decrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit") returns an empty collection of bytes on failure

UnprotectForMachine ( this binaryData, string salt = "CoAppToolkit" ) : string

decrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit") and returns a string from the UTF8 representation of the bytes. returns an empty string on failure

UnprotectForUser ( this binaryData, string salt = "CoAppToolkit" ) : string

decrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit") and returns a string from the UTF8 representation of the bytes. returns an empty string on failure

UrlDecode ( this s ) : string

decodes the URL encoded string

UrlEncode ( this s ) : string

encodes the string as a url encoded string

UrlEncodeJustBackslashes ( this s ) : string
WhenNullOrEmpty ( this original, string whenEmpty ) : string
format ( this formatString ) : string

Formats the specified format string.

Приватные методы

Метод Описание
ProcessMacroInternal ( this value, GetMacroValueDelegate getMacroValue, object eachItem = null ) : string
WildcardToRegex ( string wildcard, string noEscapePrefix = "^" ) : Regex
camelCaseToDashed ( this camelCaseText, char separator = '-' ) : IEnumerable
dashedToCamelCase ( this dashedText, char separator = '-', bool pascalCase = false ) : IEnumerable

Описание методов

CamelCaseToDashed() публичный статический Метод

public static CamelCaseToDashed ( this camelCaseText, char separator = '-' ) : string
camelCaseText this
separator char
Результат string

Contains() публичный статический Метод

public static Contains ( this text ) : bool
text this
Результат bool

ContainsAllAsWildcards() публичный статический Метод

public static ContainsAllAsWildcards ( this source ) : bool
source this
Результат bool

ContainsAnyAsWildcards() публичный статический Метод

public static ContainsAnyAsWildcards ( this source ) : bool
source this
Результат bool

ContainsIgnoreCase() публичный статический Метод

A case insensitive Contains() method.
public static ContainsIgnoreCase ( this source, string value ) : bool
source this The source.
value string The value.
Результат bool

CreateGuid() публичный статический Метод

Creates a GUID from an MD5 value of the string passed in.
public static CreateGuid ( this str ) : System.Guid
str this The STR.
Результат System.Guid

CreatePublicKeyToken() публичный статический Метод

Creates the public key token given a public key.. Note: Does this work?
public static CreatePublicKeyToken ( this publicKey ) : string
publicKey this The public key.
Результат string

DashedToCamelCase() публичный статический Метод

public static DashedToCamelCase ( this dashedText, char separator = '-' ) : string
dashedText this
separator char
Результат string

DashedToPascalCase() публичный статический Метод

public static DashedToPascalCase ( this dashedText, char separator = '-' ) : string
dashedText this
separator char
Результат string

EmptyAsNull() публичный статический Метод

public static EmptyAsNull ( this str ) : string
str this
Результат string

EqualsEx() публичный статический Метод

Checks to see if strings are equal, with empty strings being considered equal to null.
public static EqualsEx ( this str1, string str2 ) : bool
str1 this First String to compare
str2 string Second String to compare
Результат bool

Error() публичный статический Метод

Errors the specified format string.
public static Error ( this formatString ) : void
formatString this The format string.
Результат void

FormatWithMacros() публичный статический Метод

public static FormatWithMacros ( this value, GetMacroValueDelegate getMacroValue, object eachItem = null, GetMacroValueDelegate preprocessValue = null, GetMacroValueDelegate postprocessValue = null ) : string
value this
getMacroValue GetMacroValueDelegate
eachItem object
preprocessValue GetMacroValueDelegate
postprocessValue GetMacroValueDelegate
Результат string

GetKeyTokenFromFullKey() публичный статический Метод

Gets the key token from full key. Does this work?
public static GetKeyTokenFromFullKey ( this fullKey ) : byte[]
fullKey this The full key.
Результат byte[]

Gunzip() публичный статический Метод

Gunzips the specified input.
public static Gunzip ( this input ) : string
input this The input.
Результат string

GunzipFromBase64() публичный статический Метод

Gunzips from base64.
public static GunzipFromBase64 ( this input ) : string
input this The input.
Результат string

Gzip() публичный статический Метод

Gzips the specified input.
public static Gzip ( this input ) : byte[]
input this The input.
Результат byte[]

GzipToBase64() публичный статический Метод

Gzips to base64.
public static GzipToBase64 ( this input ) : string
input this The input.
Результат string

HasWildcardMatch() публичный статический Метод

Runs IsWildcardMatch on a collection.
public static HasWildcardMatch ( this source, string value, string ignorePrefix = null ) : bool
source this The source.
value string The value.
ignorePrefix string The ignore prefix.
Результат bool

HasWildcards() публичный статический Метод

Determines whether the specified input has wildcards.
public static HasWildcards ( this input ) : bool
input this The input.
Результат bool

HtmlDecode() публичный статический Метод

decodes an HTML encoded string
public static HtmlDecode ( this s ) : string
s this The string
Результат string

HtmlEncode() публичный статический Метод

Encodes a string into HTML encoding format, encoding control characters as well.
public static HtmlEncode ( this s ) : string
s this The s.
Результат string

IfNullOrEmpty() публичный статический Метод

public static IfNullOrEmpty ( this text, string defaultText ) : string
text this
defaultText string
Результат string

Is() публичный статический Метод

public static Is ( this str ) : bool
str this
Результат bool

IsBoolean() публичный статический Метод

Determines whether the specified text is a boolean (true or false).
public static IsBoolean ( this text ) : bool
text this The text.
Результат bool

IsEmail() публичный статический Метод

Determines whether the specified email is email.
public static IsEmail ( this email ) : bool
email this The email.
Результат bool

IsFalse() публичный статический Метод

Determines whether the specified text is equal to "false" (ignoring case).
public static IsFalse ( this text ) : bool
text this The text.
Результат bool

IsMultiline() публичный статический Метод

public static IsMultiline ( this text ) : bool
text this
Результат bool

IsNegative() публичный статический Метод

Determines whether the specified text is equal to some value indicated negative/off/false/no (ignoring case).
public static IsNegative ( this text ) : bool
text this The text.
Результат bool

IsPositive() публичный статический Метод

Determines whether the specified text equal to some value indicated on/true/enabled (ignoring case).
public static IsPositive ( this text ) : bool
text this The text.
Результат bool

IsTrue() публичный статический Метод

Determines whether the specified text equal to "true" (ignoring case).
public static IsTrue ( this text ) : bool
text this The text.
Результат bool

IsWebUri() публичный статический Метод

public static IsWebUri ( this text ) : bool
text this
Результат bool

MD5Hash() публичный статический Метод

Calculates the MD5 hash of a string. Additionally all the letters in the hash are in uppercase.
public static MD5Hash ( this input ) : string
input this a string to a calculate the hash for
Результат string

MakeAttractiveFilename() публичный статический Метод

public static MakeAttractiveFilename ( this input ) : string
input this
Результат string

MakeSafeDirectoryId() публичный статический Метод

Creates a safe directory ID for MSI for a possibly non-safe one.
public static MakeSafeDirectoryId ( this input ) : string
input this The input.
Результат string

MakeSafeFileName() публичный статический Метод

public static MakeSafeFileName ( this input ) : string
input this
Результат string

Match() публичный статический Метод

Matches the specified input.
public static Match ( this input, string rxExpression ) : Match
input this The input.
rxExpression string The rx expression.
Результат System.Text.RegularExpressions.Match

MatchIgnoreCase() публичный статический Метод

Matches a regular expression, ignoring case.
public static MatchIgnoreCase ( this input, string rxExpression ) : Match
input this The input.
rxExpression string The rx expression.
Результат System.Text.RegularExpressions.Match

NewIsWildcardMatch() публичный статический Метод

The new implementation of the wildcard matching function. Rules: * means matches anything except slash or backslash ? means match any one character ** means matches anything
public static NewIsWildcardMatch ( this text, string wildcardMask, bool isMatchingLocation = false, string currentLocation = null ) : bool
text this
wildcardMask string
isMatchingLocation bool
currentLocation string
Результат bool

OnlyContains() публичный статический Метод

returns true when the string contains only the characters passed in.
public static OnlyContains ( this str, char characters ) : bool
str this The STR.
characters char The characters.
Результат bool

OnlyContains() публичный статический Метод

returns true when the string contains only the characters in the string passed in .
public static OnlyContains ( this str, string characters ) : bool
str this The STR.
characters string The characters.
Результат bool

PositionOfFirstCharacterNotIn() публичный статический Метод

Gets the position of the first character that is not in the collection of characters passed in.
public static PositionOfFirstCharacterNotIn ( this str, char characters ) : int
str this The STR.
characters char The characters.
Результат int

PositionOfFirstCharacterNotIn() публичный статический Метод

Gets the position of the first character that is not in the string passed in.
public static PositionOfFirstCharacterNotIn ( this str, string characters ) : int
str this The STR.
characters string The characters.
Результат int

ProtectBinaryForMachine() публичный статический Метод

encrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit")
public static ProtectBinaryForMachine ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable
binaryData this The binary data.
salt string The salt.
Результат IEnumerable

ProtectBinaryForUser() публичный статический Метод

encrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit")
public static ProtectBinaryForUser ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable
binaryData this The binary data.
salt string The salt.
Результат IEnumerable

ProtectForMachine() публичный статический Метод

encrypts the given string with the machine key and salt (defaults to "CoAppToolkit")
public static ProtectForMachine ( this text, string salt = "CoAppToolkit" ) : IEnumerable
text this The text.
salt string The salt.
Результат IEnumerable

ProtectForUser() публичный статический Метод

encrypts the given string with the machine key and salt (defaults to "CoAppToolkit")
public static ProtectForUser ( this text, string salt = "CoAppToolkit" ) : IEnumerable
text this The text.
salt string The salt.
Результат IEnumerable

Replace() публичный статический Метод

Case insensitive version of String.Replace().
public static Replace ( this s, string oldValue, string newValue, System.StringComparison comparisonType ) : string
s this String that contains patterns to replace
oldValue string Pattern to find
newValue string New pattern to replaces old
comparisonType System.StringComparison String comparison type
Результат string

StartsWithNumber() публичный статический Метод

public static StartsWithNumber ( this str ) : bool
str this
Результат bool

ToByteArray() публичный статический Метод

Encodes the string as an array of UTF8 bytes.
public static ToByteArray ( this text ) : byte[]
text this The text.
Результат byte[]

ToHexString() публичный статический Метод

Creates a hex representaion of a collection of bytes
public static ToHexString ( this bytes ) : string
bytes this The bytes.
Результат string

ToInt32() публичный статический Метод

coerces a string to an int32, defaults to zero.
public static ToInt32 ( this str ) : int
str this The STR.
Результат int

ToInt32() публичный статический Метод

coerces a string to an int32, defaults to zero.
public static ToInt32 ( this str, int defaultValue ) : int
str this The STR.
defaultValue int The default value if the string isn't a valid int.
Результат int

ToSecureString() публичный статический Метод

public static ToSecureString ( this password ) : SecureString
password this
Результат System.Security.SecureString

ToUnsecureString() публичный статический Метод

public static ToUnsecureString ( this securePassword ) : string
securePassword this
Результат string

ToUri() публичный статический Метод

public static ToUri ( this stringUri ) : Uri
stringUri this
Результат System.Uri

ToUtf8String() публичный статический Метод

Creates a string from a collection of UTF8 bytes
public static ToUtf8String ( this bytes ) : string
bytes this The bytes.
Результат string

UnprotectBinaryForMachine() публичный статический Метод

decrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit") returns an empty collection of bytes on failure
public static UnprotectBinaryForMachine ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable
binaryData this The binary data.
salt string The salt.
Результат IEnumerable

UnprotectBinaryForUser() публичный статический Метод

decrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit") returns an empty collection of bytes on failure
public static UnprotectBinaryForUser ( this binaryData, string salt = "CoAppToolkit" ) : IEnumerable
binaryData this The binary data.
salt string The salt.
Результат IEnumerable

UnprotectForMachine() публичный статический Метод

decrypts the given collection of bytes with the machine key and salt (defaults to "CoAppToolkit") and returns a string from the UTF8 representation of the bytes. returns an empty string on failure
public static UnprotectForMachine ( this binaryData, string salt = "CoAppToolkit" ) : string
binaryData this The binary data.
salt string The salt.
Результат string

UnprotectForUser() публичный статический Метод

decrypts the given collection of bytes with the user key and salt (defaults to "CoAppToolkit") and returns a string from the UTF8 representation of the bytes. returns an empty string on failure
public static UnprotectForUser ( this binaryData, string salt = "CoAppToolkit" ) : string
binaryData this The binary data.
salt string The salt.
Результат string

UrlDecode() публичный статический Метод

decodes the URL encoded string
public static UrlDecode ( this s ) : string
s this The s.
Результат string

UrlEncode() публичный статический Метод

encodes the string as a url encoded string
public static UrlEncode ( this s ) : string
s this The s.
Результат string

UrlEncodeJustBackslashes() публичный статический Метод

public static UrlEncodeJustBackslashes ( this s ) : string
s this
Результат string

WhenNullOrEmpty() публичный статический Метод

public static WhenNullOrEmpty ( this original, string whenEmpty ) : string
original this
whenEmpty string
Результат string

format() публичный статический Метод

Formats the specified format string.
public static format ( this formatString ) : string
formatString this The format string.
Результат string