C# Class Utilities.DataTypes.StringExtensions

Mostra file Open project: JaCraig/Craig-s-Utility-Library

Public Methods

Method Description
AppendLineFormat ( this Builder, string Format ) : StringBuilder

Does an AppendFormat and then an AppendLine on the StringBuilder

Center ( this Input, int Length, string Padding = " " ) : string

Centers the input string (if it's longer than the length) and pads it using the padding string

Encode ( this Input, Encoding OriginalEncodingUsing = null, Encoding EncodingUsing = null ) : string

Converts a string to a string of another encoding

FromBase64 ( this Input ) : byte[]

Converts base 64 string to a byte array

FromBase64 ( this Input, Encoding EncodingUsing ) : string

Converts base 64 string based on the encoding passed in

Is ( this Value, StringCompare ComparisonType ) : bool

Is this value of the specified type

Is ( this Value1, string Value2, StringCompare ComparisonType ) : bool

Is this value of the specified type

Keep ( this Input, StringFilter Filter ) : string

Removes everything that is not in the filter text from the input.

Keep ( this Input, string Filter ) : string

Removes everything that is not in the filter text from the input.

Left ( this Input, int Length ) : string

Gets the first x number of characters from the left hand side

LevenshteinDistance ( this Value1, string Value2 ) : int

Calculates the Levenshtein distance

MaskLeft ( this Input, int EndPosition = 4, char Mask = '#' ) : string

Masks characters to the left ending at a specific character

MaskRight ( this Input, int StartPosition = 4, char Mask = '#' ) : string

Masks characters to the right starting at a specific character

NumberTimesOccurs ( this Input, string Match ) : int

returns the number of times a string occurs within the text

Pluralize ( this Word, CultureInfo Culture = null ) : string

Pluralizes a word

Remove ( this Input, StringFilter Filter ) : string

Removes everything that is in the filter text from the input.

Remove ( this Input, string Filter ) : string

Removes everything that is in the filter text from the input.

Replace ( this Input, StringFilter Filter, string Value = "" ) : string

Replaces everything that is in the filter text with the value specified.

Reverse ( this Input ) : string

Reverses a string

Right ( this Input, int Length ) : string

Gets the last x number of characters from the right hand side

Singularize ( this Word, CultureInfo Culture = null ) : string

Singularizes a word

StripIllegalXML ( this Content ) : string

Strips illegal characters for XML content

StripLeft ( this Input, string Characters = " " ) : string

Strips out any of the characters specified starting on the left side of the input string (stops when a character not in the list is found)

StripRight ( this Input, string Characters = " " ) : string

Strips out any of the characters specified starting on the right side of the input string (stops when a character not in the list is found)

ToByteArray ( this Input, Encoding EncodingUsing = null ) : byte[]

Converts a string to a byte array

ToString ( this Input ) : string

Formats a string based on the key/value pairs that are sent in

ToString ( this Input, Base64FormattingOptions Options, Encoding OriginalEncodingUsing = null ) : string

Converts from the specified encoding to a base 64 string

ToString ( this Input, StringCase Case ) : string

Formats the string based on the capitalization specified

ToString ( this Input, object Object, string StartSeperator = "{", string EndSeperator = "}" ) : string

Formats a string based on the object's properties

ToString ( this Input, string Format, IStringFormatter Provider = null ) : string

Formats a string based on a format string passed in. The default formatter uses the following format: # = digits @ = alpha characters \ = escape char

ToString ( this Input, string Format, string OutputFormat, RegexOptions Options = RegexOptions.None ) : string

Uses a regex to format the input string

Private Methods

Method Description
BuildFilter ( StringFilter Filter ) : string

Method Details

AppendLineFormat() public static method

Does an AppendFormat and then an AppendLine on the StringBuilder
public static AppendLineFormat ( this Builder, string Format ) : StringBuilder
Builder this Builder object
Format string Format string
return StringBuilder

Center() public static method

Centers the input string (if it's longer than the length) and pads it using the padding string
public static Center ( this Input, int Length, string Padding = " " ) : string
Input this
Length int
Padding string
return string

Encode() public static method

Converts a string to a string of another encoding
public static Encode ( this Input, Encoding OriginalEncodingUsing = null, Encoding EncodingUsing = null ) : string
Input this input string
OriginalEncodingUsing System.Text.Encoding /// The type of encoding the string is currently using (defaults to ASCII) ///
EncodingUsing System.Text.Encoding /// The type of encoding the string is converted into (defaults to UTF8) ///
return string

FromBase64() public static method

Converts base 64 string to a byte array
public static FromBase64 ( this Input ) : byte[]
Input this Input string
return byte[]

FromBase64() public static method

Converts base 64 string based on the encoding passed in
public static FromBase64 ( this Input, Encoding EncodingUsing ) : string
Input this Input string
EncodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
return string

Is() public static method

Is this value of the specified type
public static Is ( this Value, StringCompare ComparisonType ) : bool
Value this Value to compare
ComparisonType StringCompare Comparison type
return bool

Is() public static method

Is this value of the specified type
public static Is ( this Value1, string Value2, StringCompare ComparisonType ) : bool
Value1 this Value 1 to compare
Value2 string Value 2 to compare
ComparisonType StringCompare Comparison type
return bool

Keep() public static method

Removes everything that is not in the filter text from the input.
public static Keep ( this Input, StringFilter Filter ) : string
Input this Input text
Filter StringFilter Predefined filter to use (can be combined as they are flags)
return string

Keep() public static method

Removes everything that is not in the filter text from the input.
public static Keep ( this Input, string Filter ) : string
Input this Input text
Filter string Regex expression of text to keep
return string

Left() public static method

Gets the first x number of characters from the left hand side
public static Left ( this Input, int Length ) : string
Input this Input string
Length int x number of characters to return
return string

LevenshteinDistance() public static method

Calculates the Levenshtein distance
public static LevenshteinDistance ( this Value1, string Value2 ) : int
Value1 this Value 1
Value2 string Value 2
return int

MaskLeft() public static method

Masks characters to the left ending at a specific character
public static MaskLeft ( this Input, int EndPosition = 4, char Mask = '#' ) : string
Input this Input string
EndPosition int End position (counting from the left)
Mask char Mask character to use
return string

MaskRight() public static method

Masks characters to the right starting at a specific character
public static MaskRight ( this Input, int StartPosition = 4, char Mask = '#' ) : string
Input this Input string
StartPosition int Start position (counting from the left)
Mask char Mask character to use
return string

NumberTimesOccurs() public static method

returns the number of times a string occurs within the text
public static NumberTimesOccurs ( this Input, string Match ) : int
Input this input text
Match string The string to match (can be regex)
return int

Pluralize() public static method

Pluralizes a word
public static Pluralize ( this Word, CultureInfo Culture = null ) : string
Word this Word to pluralize
Culture System.Globalization.CultureInfo /// Culture info used to pluralize the word (defaults to current culture) ///
return string

Remove() public static method

Removes everything that is in the filter text from the input.
public static Remove ( this Input, StringFilter Filter ) : string
Input this Input text
Filter StringFilter Predefined filter to use (can be combined as they are flags)
return string

Remove() public static method

Removes everything that is in the filter text from the input.
public static Remove ( this Input, string Filter ) : string
Input this Input text
Filter string Regex expression of text to remove
return string

Replace() public static method

Replaces everything that is in the filter text with the value specified.
public static Replace ( this Input, StringFilter Filter, string Value = "" ) : string
Input this Input text
Filter StringFilter Predefined filter to use (can be combined as they are flags)
Value string Value to fill in
return string

Reverse() public static method

Reverses a string
public static Reverse ( this Input ) : string
Input this Input string
return string

Right() public static method

Gets the last x number of characters from the right hand side
public static Right ( this Input, int Length ) : string
Input this Input string
Length int x number of characters to return
return string

Singularize() public static method

Singularizes a word
public static Singularize ( this Word, CultureInfo Culture = null ) : string
Word this Word to singularize
Culture System.Globalization.CultureInfo /// Culture info used to singularize the word (defaults to current culture) ///
return string

StripIllegalXML() public static method

Strips illegal characters for XML content
public static StripIllegalXML ( this Content ) : string
Content this Content
return string

StripLeft() public static method

Strips out any of the characters specified starting on the left side of the input string (stops when a character not in the list is found)
public static StripLeft ( this Input, string Characters = " " ) : string
Input this Input string
Characters string Characters to strip (defaults to a space)
return string

StripRight() public static method

Strips out any of the characters specified starting on the right side of the input string (stops when a character not in the list is found)
public static StripRight ( this Input, string Characters = " " ) : string
Input this Input string
Characters string Characters to strip (defaults to a space)
return string

ToByteArray() public static method

Converts a string to a byte array
public static ToByteArray ( this Input, Encoding EncodingUsing = null ) : byte[]
Input this input string
EncodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
return byte[]

ToString() public static method

Formats a string based on the key/value pairs that are sent in
public static ToString ( this Input ) : string
Input this Input string
return string

ToString() public static method

Converts from the specified encoding to a base 64 string
public static ToString ( this Input, Base64FormattingOptions Options, Encoding OriginalEncodingUsing = null ) : string
Input this Input string
Options Base64FormattingOptions Base 64 formatting options
OriginalEncodingUsing System.Text.Encoding /// The type of encoding the string is using (defaults to UTF8) ///
return string

ToString() public static method

Formats the string based on the capitalization specified
public static ToString ( this Input, StringCase Case ) : string
Input this Input string
Case StringCase Capitalization type to use
return string

ToString() public static method

Formats a string based on the object's properties
public static ToString ( this Input, object Object, string StartSeperator = "{", string EndSeperator = "}" ) : string
Input this Input string
Object object Object to use to format the string
StartSeperator string /// Seperator character/string to use to describe the start of the property name ///
EndSeperator string /// Seperator character/string to use to describe the end of the property name ///
return string

ToString() public static method

Formats a string based on a format string passed in. The default formatter uses the following format: # = digits @ = alpha characters \ = escape char
public static ToString ( this Input, string Format, IStringFormatter Provider = null ) : string
Input this Input string
Format string Format of the output string
Provider IStringFormatter String formatter provider (defaults to GenericStringFormatter)
return string

ToString() public static method

Uses a regex to format the input string
public static ToString ( this Input, string Format, string OutputFormat, RegexOptions Options = RegexOptions.None ) : string
Input this Input string
Format string Regex string used to
OutputFormat string Output format
Options RegexOptions Regex options
return string