C# 클래스 Nvelope.StringExtensions

파일 보기 프로젝트 열기: TrinityWestern/Nvelope

공개 메소드들

메소드 설명
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