C# Класс Nvelope.StringExtensions

Показать файл Открыть проект

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

Метод Описание
Camelize ( this input, bool capitalizeFirst = false ) : string

Converts the input to camelCase

ChopEnd ( this source ) : string

Remove whitespace from source, and trim off any stringsToRemove if source ends with it

ChopStart ( this source ) : string

Remove whitespace from source, and trim off stringToRemove if source starts with it

ContainsAll ( this source ) : bool
ContainsAll ( this source, IEnumerable strings ) : bool
ContainsAny ( this source ) : bool
ContainsAny ( this source, IEnumerable strings ) : bool
EscapePowerShell ( this sentence ) : string

Assuming that your string in PowerShell is wrapped in double quotes, this will escape all of the characters in your sentence so that you can have things like passwords with back-ticks, ampersands, single-quotes, etc.

Excerpt ( this original, int maxLength ) : string

Limit the length of a string while keeping words intact, and adding ... to the end

FormatFromDictionary ( this str, string>.IDictionary dict ) : string

Functions like string.Format, only with a dictionary of values From: http://stackoverflow.com/questions/1010123/named-string-format-is-it-possible-c

IsNullOrEmpty ( this source ) : bool

Just a wrapper around String.IsNullOrEmpty so you can call it inline

Join ( this source, string seperator ) : string

Joins a list of strings together into a single string

Print ( this s ) : string This exists so that the compiler doesn't get confused and call the IEnumerable[char] version of Print on a string. Then you would get "(a,b)" from "ab".Print(), which is silly
RemoveEnd ( this source, int count ) : string

Removes the last 'count' number of characters. If the ask to remove a greater number of characters than exist in source returns an empty string.

Repeat ( this source, int times ) : string

Repeat a string times times

RetrieveIntFromAString ( string input ) : string

This method retrieves digits from a string

SentenceCase ( this sentence ) : string
Split ( this source, string splitby ) : string[]

Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. A parameter specifies whether to return empty array elements.

SplitPair ( this source, string splitby ) : string[]

Returns an array of two strings that are separated by the specified string.

Strip ( this source ) : string

Removes all instances of the supplied victims string(s)

This is not the same as Trim

SubstringAfter ( this source, string splitter ) : string

Gets the part of the string that comes after the given token. If the given token is not in the string, this returns null.

SubstringBefore ( this source, string splitter ) : string

Gets the part of the string that comes before the given token. If the given token is not in the string, this returns null.

ToLength ( this source, int length ) : string

Make the string the specified length - truncating or appending spaces as necessary

ToStringN ( this source ) : string

Converts to string, but handles null gracefully (converts to "")

Tokenize ( this source ) : IEnumerable

Splits the string by spaces

Tokenize ( this source, string regexExpression ) : IEnumerable

TrimN ( this source ) : string

Trim(), but handle nulls, leaving them as nulls

Truncate ( this source, int maxLength ) : string

Truncates a string down to the specified maxLength

UnCamelize ( this input, bool unCapitalize = false ) : string

Converts the input from camelCase to space seperated

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

Метод Описание
FindIntInString ( string input ) : string
GetEmailInParenthesis ( this source ) : string
GetIntegerInParenthesis ( this source ) : int?
NumTimesCharacterRepeatsAtEnd ( this original, char charToCheck ) : int
RetrieveIntInString ( string input ) : int
SemiClean ( string input ) : string
ToDoubleAsStringOr0 ( this source ) : string
ToIntOr0 ( this source ) : int
Tokenize ( this source, Regex regex ) : IEnumerable

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

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

Converts the input to camelCase
public static Camelize ( this input, bool capitalizeFirst = false ) : string
input this
capitalizeFirst bool
Результат string

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

Remove whitespace from source, and trim off any stringsToRemove if source ends with it
public static ChopEnd ( this source ) : string
source this
Результат string

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

Remove whitespace from source, and trim off stringToRemove if source starts with it
public static ChopStart ( this source ) : string
source this
Результат string

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

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

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

public static ContainsAll ( this source, IEnumerable strings ) : bool
source this
strings IEnumerable
Результат bool

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

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

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

public static ContainsAny ( this source, IEnumerable strings ) : bool
source this
strings IEnumerable
Результат bool

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

Assuming that your string in PowerShell is wrapped in double quotes, this will escape all of the characters in your sentence so that you can have things like passwords with back-ticks, ampersands, single-quotes, etc.
public static EscapePowerShell ( this sentence ) : string
sentence this
Результат string

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

Limit the length of a string while keeping words intact, and adding ... to the end
public static Excerpt ( this original, int maxLength ) : string
original this String to make an excerpt of
maxLength int Maximum length of the string (including the ...)
Результат string

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

Functions like string.Format, only with a dictionary of values From: http://stackoverflow.com/questions/1010123/named-string-format-is-it-possible-c
public static FormatFromDictionary ( this str, string>.IDictionary dict ) : string
str this String to form
dict string>.IDictionary Dictionary to retrieve values from
Результат string

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

Just a wrapper around String.IsNullOrEmpty so you can call it inline
public static IsNullOrEmpty ( this source ) : bool
source this
Результат bool

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

Joins a list of strings together into a single string
public static Join ( this source, string seperator ) : string
source this
seperator string
Результат string

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

This exists so that the compiler doesn't get confused and call the IEnumerable[char] version of Print on a string. Then you would get "(a,b)" from "ab".Print(), which is silly
public static Print ( this s ) : string
s this
Результат string

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

Removes the last 'count' number of characters. If the ask to remove a greater number of characters than exist in source returns an empty string.
public static RemoveEnd ( this source, int count ) : string
source this
count int
Результат string

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

Repeat a string times times
public static Repeat ( this source, int times ) : string
source this
times int
Результат string

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

This method retrieves digits from a string
public static RetrieveIntFromAString ( string input ) : string
input string anything in a string
Результат string

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

public static SentenceCase ( this sentence ) : string
sentence this
Результат string

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

Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. A parameter specifies whether to return empty array elements.
public static Split ( this source, string splitby ) : string[]
source this The source string, usually the object you're calling the Extension method on.
splitby string The token to split by.
Результат string[]

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

Returns an array of two strings that are separated by the specified string.
public static SplitPair ( this source, string splitby ) : string[]
source this The source string to be split into two items.
splitby string The string that the source is to be split by.
Результат string[]

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

Removes all instances of the supplied victims string(s)
This is not the same as Trim
public static Strip ( this source ) : string
source this
Результат string

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

Gets the part of the string that comes after the given token. If the given token is not in the string, this returns null.
public static SubstringAfter ( this source, string splitter ) : string
source this The source string, usually the object you're calling the Extension method on.
splitter string The token to look for and use to split the string in two pieces
Результат string

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

Gets the part of the string that comes before the given token. If the given token is not in the string, this returns null.
public static SubstringBefore ( this source, string splitter ) : string
source this The source string, usually the object you're calling the Extension method on.
splitter string The token to look for and use to split the string in two pieces
Результат string

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

Make the string the specified length - truncating or appending spaces as necessary
public static ToLength ( this source, int length ) : string
source this
length int
Результат string

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

Converts to string, but handles null gracefully (converts to "")
public static ToStringN ( this source ) : string
source this
Результат string

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

Splits the string by spaces
public static Tokenize ( this source ) : IEnumerable
source this
Результат IEnumerable

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

public static Tokenize ( this source, string regexExpression ) : IEnumerable
source this
regexExpression string An regex used to tokenize the string - the entire contents of the expression will /// be removed with each iteration, and the value of group 1 will be returned as the token value
Результат IEnumerable

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

Trim(), but handle nulls, leaving them as nulls
public static TrimN ( this source ) : string
source this
Результат string

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

Truncates a string down to the specified maxLength
public static Truncate ( this source, int maxLength ) : string
source this
maxLength int
Результат string

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

Converts the input from camelCase to space seperated
public static UnCamelize ( this input, bool unCapitalize = false ) : string
input this
unCapitalize bool
Результат string