C# 클래스 Candor.StringExtensions

Various common use case extensions to System.String.
파일 보기 프로젝트 열기: michael-lang/candor-common

공개 메소드들

메소드 설명
CamelCaseToPhrase ( this text ) : string

Puts spaces in a camel cased string before each capital letter and makes the capital letters lower case.

GenerateTeaser ( this text, Int32 maxSentences, Int32 maxCharacters ) : string

Generates a teaser phrase from any body of text. If the text is shortened from the specified max length, an ellipsis ("...") is added.

LexicalAdd ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase, System.Boolean treatNonCharsAsSpace, Int32 count ) : String

Performs a lexicographical addition to a string by any amount. See http://wikipedia.org/wiki/Lexicographical_order, and further remarks for this member.

This may or may not result in a value that sorts in the correct order as if it were a file name in a file explorer.

If the string is at the highest character for each position or the number added moves past that position, then a new character position is incremented to the left (by adding a character position). This then behaves the same as if the source was left whitespace padded. Performance scales based on the number of characters incremented in the string.

Incrementing the value always starts on the right and moves left as with numeric additions. Right whitespace padded strings will increment values in the whitespace before advancing to the characters on the left. If this is not desired behavior then Trim the source when passed into this method.

LexicalAdd ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase, Int32 count ) : String

Performs a lexicographical addition to a string by any amount. See http://wikipedia.org/wiki/Lexicographical_order, and further remarks for this member.

This may or may not result in a value that sorts in the correct order as if it were a file name in a file explorer.

If the string is at the highest character for each position or the number added moves past that position, then a new character position is incremented to the left (by adding a character position). This then behaves the same as if the source was left whitespace padded. Performance scales based on the number of characters incremented in the string.

Incrementing the value always starts on the right and moves left as with numeric additions. Right whitespace padded strings will increment values in the whitespace before advancing to the characters on the left. If this is not desired behavior then Trim the source when passed into this method.

LexicalIncrement ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase ) : String

Increments a source string to the next logical higher value. Characters are incremented without altering length first. If all character positions are at the highest character, then a new lowest value character is added to the end.

RemoveDiacritics ( this text ) : string

Removes diacritics from a text body.

a sign, such as an accent or cedilla, which when written above or below a letter indicates a difference in pronunciation from the same letter when unmarked or differently marked.

ReplaceNotIn ( this text, IList chars, String replacement ) : string

Replaces all characters in a text string that are not in a given list.

ToDigitsOnly ( this input ) : string

Gets only the digits portion of a string.

ToPascalCase ( this text ) : string

Converts a sentence or _ separated word string into a no whitespace/underscore pascal case name.

ToProperNameCase ( this text ) : string

Converts a string to a format of a proper name. Each word is capitalized. underscores become spaces (word boundaries). Acronyms are assumed when the text is all letters in all caps, and then no change is made.

ToSentence ( this text ) : string

Converts a string to a sentence, making word boundaries at capital letters following a lower case letter and replacing underscores with a space.

TrimEndNotIn ( this text, IList chars ) : string

Trims any characters from the end of a string that is not in the supplied list.

TrimNotIn ( this text, IList chars ) : string

Trims any characters from the start and end of a string that is not in the supplied list.

TrimStartNotIn ( this text, IList chars ) : string

Trims any characters from the start of a string that is not in the supplied list.

메소드 상세

CamelCaseToPhrase() 공개 정적인 메소드

Puts spaces in a camel cased string before each capital letter and makes the capital letters lower case.
public static CamelCaseToPhrase ( this text ) : string
text this
리턴 string

GenerateTeaser() 공개 정적인 메소드

Generates a teaser phrase from any body of text. If the text is shortened from the specified max length, an ellipsis ("...") is added.
public static GenerateTeaser ( this text, Int32 maxSentences, Int32 maxCharacters ) : string
text this The original body text.
maxSentences System.Int32 The max number of sentences from the original text.
maxCharacters System.Int32 The maximum total characters to return.
리턴 string

LexicalAdd() 공개 정적인 메소드

Performs a lexicographical addition to a string by any amount. See http://wikipedia.org/wiki/Lexicographical_order, and further remarks for this member.

This may or may not result in a value that sorts in the correct order as if it were a file name in a file explorer.

If the string is at the highest character for each position or the number added moves past that position, then a new character position is incremented to the left (by adding a character position). This then behaves the same as if the source was left whitespace padded. Performance scales based on the number of characters incremented in the string.

Incrementing the value always starts on the right and moves left as with numeric additions. Right whitespace padded strings will increment values in the whitespace before advancing to the characters on the left. If this is not desired behavior then Trim the source when passed into this method.

public static LexicalAdd ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase, System.Boolean treatNonCharsAsSpace, Int32 count ) : String
source this The string to increment from.
charSet LexicalCharacterSet The character set defining the characters and their order.
ignoreCase System.Boolean Specifies if case should be ignored as an incremented value. /// If true, incremented character positions will be the case of the majority of other /// values; which may or may not be the same as the character being replaced.
treatNonCharsAsSpace System.Boolean /// Indicates if non character set characters should be treated as /// a space and be eligible for incrementing. ///
count System.Int32
리턴 String

LexicalAdd() 공개 정적인 메소드

Performs a lexicographical addition to a string by any amount. See http://wikipedia.org/wiki/Lexicographical_order, and further remarks for this member.

This may or may not result in a value that sorts in the correct order as if it were a file name in a file explorer.

If the string is at the highest character for each position or the number added moves past that position, then a new character position is incremented to the left (by adding a character position). This then behaves the same as if the source was left whitespace padded. Performance scales based on the number of characters incremented in the string.

Incrementing the value always starts on the right and moves left as with numeric additions. Right whitespace padded strings will increment values in the whitespace before advancing to the characters on the left. If this is not desired behavior then Trim the source when passed into this method.

public static LexicalAdd ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase, Int32 count ) : String
source this The string to increment from.
charSet LexicalCharacterSet The character set defining the characters and their order.
ignoreCase System.Boolean Specifies if case should be ignored as an incremented value. /// If true, incremented character positions will be the case of the majority of other /// values; which may or may not be the same as the character being replaced.
count System.Int32
리턴 String

LexicalIncrement() 공개 정적인 메소드

Increments a source string to the next logical higher value. Characters are incremented without altering length first. If all character positions are at the highest character, then a new lowest value character is added to the end.
public static LexicalIncrement ( this source, LexicalCharacterSet charSet, System.Boolean ignoreCase ) : String
source this The source string.
charSet LexicalCharacterSet The character set to use. If the source string characters do not all fit in this set, an exception is thrown.
ignoreCase System.Boolean Specified if case is to be ignored for alpha characters.
리턴 String

RemoveDiacritics() 공개 정적인 메소드

Removes diacritics from a text body.
a sign, such as an accent or cedilla, which when written above or below a letter indicates a difference in pronunciation from the same letter when unmarked or differently marked.
public static RemoveDiacritics ( this text ) : string
text this
리턴 string

ReplaceNotIn() 공개 정적인 메소드

Replaces all characters in a text string that are not in a given list.
public static ReplaceNotIn ( this text, IList chars, String replacement ) : string
text this The text to be scanned.
chars IList The characters to be kept, such as a LexicalCharacterSet characters list.
replacement String The string to put in place of each character not in 'chars'.
리턴 string

ToDigitsOnly() 공개 정적인 메소드

Gets only the digits portion of a string.
public static ToDigitsOnly ( this input ) : string
input this
리턴 string

ToPascalCase() 공개 정적인 메소드

Converts a sentence or _ separated word string into a no whitespace/underscore pascal case name.
public static ToPascalCase ( this text ) : string
text this
리턴 string

ToProperNameCase() 공개 정적인 메소드

Converts a string to a format of a proper name. Each word is capitalized. underscores become spaces (word boundaries). Acronyms are assumed when the text is all letters in all caps, and then no change is made.
public static ToProperNameCase ( this text ) : string
text this
리턴 string

ToSentence() 공개 정적인 메소드

Converts a string to a sentence, making word boundaries at capital letters following a lower case letter and replacing underscores with a space.
public static ToSentence ( this text ) : string
text this
리턴 string

TrimEndNotIn() 공개 정적인 메소드

Trims any characters from the end of a string that is not in the supplied list.
public static TrimEndNotIn ( this text, IList chars ) : string
text this The text to be scanned.
chars IList The characters to be kept, such as a LexicalCharacterSet characters list.
리턴 string

TrimNotIn() 공개 정적인 메소드

Trims any characters from the start and end of a string that is not in the supplied list.
public static TrimNotIn ( this text, IList chars ) : string
text this The text to be scanned.
chars IList The characters to be kept, such as a LexicalCharacterSet characters list.
리턴 string

TrimStartNotIn() 공개 정적인 메소드

Trims any characters from the start of a string that is not in the supplied list.
public static TrimStartNotIn ( this text, IList chars ) : string
text this The text to be scanned.
chars IList The characters to be kept, such as a LexicalCharacterSet characters list.
리턴 string