C# Class Icing.StringExtensions

String extensions.
显示文件 Open project: benallred/Icing

Public Methods

Method Description
DoesNotEndWith ( this source, string value ) : bool

Determines whether the end of this string instance does not match the specified string.

EnsureEndsWith ( this source, string value ) : string

Returns the current string instance with the specified value appended, if the current string instance does not already end with the specified value.

Format ( this source, string>.IDictionary replacements ) : string

Returns a new string in which all occurrences of the specified tokens in the current instance are replaced with the provided replacement values.

A token is designated in a string by surrounding it with curly braces (example: {MyToken}).

A token must consist of one or more valid "word characters" (think valid variable name) and is case-sensitive.

Curly braces can be escaped by using double braces. The double braces will be replaced with single braces (example: "{{something}}" becomes "{something}").

Any token without a replacement value specified will be untouched and appear in the returned string exactly as in the source.

Format ( this source, object replacements ) : string

Returns a new string in which all occurrences of the specified tokens in the current instance are replaced with the provided replacement values.

A token is designated in a string by surrounding it with curly braces (example: {MyToken}).

A token must consist of one or more valid "word characters" (think valid variable name) and is case-sensitive.

Curly braces can be escaped by using double braces. The double braces will be replaced with single braces (example: "{{something}}" becomes "{something}").

Any token without a replacement value specified will be untouched and appear in the returned string exactly as in the source.

IsNotNullOrEmpty ( this source ) : bool

Indicates whether the current string is not null and not an System.String.Empty string.

IsNotNullOrWhiteSpace ( this source ) : bool

Indicates whether the current string is not null, not empty, and does not consist only of white-space characters.

IsNullOrEmpty ( this source ) : bool

Indicates whether the current string is null or an System.String.Empty string.

IsNullOrWhiteSpace ( this source ) : bool

Indicates whether the current string is null, empty, or consists only of white-space characters.

PadNumber ( this source, int maxNumberToMatch, char paddingChar = '0' ) : string

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.

PadNumber ( this source, long maxNumberToMatch, char paddingChar = '0' ) : string

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.

PadNumber ( this source, uint maxNumberToMatch, char paddingChar = '0' ) : string

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.

Reverse ( this source ) : string

Reverses the sequence of the characters in the entire string.

ToInt32 ( this source ) : int

Converts the current string representation of a number to its 32-bit signed integer equivalent.

Trim ( this source, string trim ) : string

Removes all leading and trailing occurrences of the given string from the current String object.

Method Details

DoesNotEndWith() public static method

Determines whether the end of this string instance does not match the specified string.
public static DoesNotEndWith ( this source, string value ) : bool
source this The string to test.
value string The string to compare to the substring at the end of this instance.
return bool

EnsureEndsWith() public static method

Returns the current string instance with the specified value appended, if the current string instance does not already end with the specified value.
public static EnsureEndsWith ( this source, string value ) : string
source this The source string.
value string The value to append.
return string

Format() public static method

Returns a new string in which all occurrences of the specified tokens in the current instance are replaced with the provided replacement values.

A token is designated in a string by surrounding it with curly braces (example: {MyToken}).

A token must consist of one or more valid "word characters" (think valid variable name) and is case-sensitive.

Curly braces can be escaped by using double braces. The double braces will be replaced with single braces (example: "{{something}}" becomes "{something}").

Any token without a replacement value specified will be untouched and appear in the returned string exactly as in the source.

public static Format ( this source, string>.IDictionary replacements ) : string
source this The source string.
replacements string>.IDictionary The replacement values.
return string

Format() public static method

Returns a new string in which all occurrences of the specified tokens in the current instance are replaced with the provided replacement values.

A token is designated in a string by surrounding it with curly braces (example: {MyToken}).

A token must consist of one or more valid "word characters" (think valid variable name) and is case-sensitive.

Curly braces can be escaped by using double braces. The double braces will be replaced with single braces (example: "{{something}}" becomes "{something}").

Any token without a replacement value specified will be untouched and appear in the returned string exactly as in the source.

public static Format ( this source, object replacements ) : string
source this The source string.
replacements object The replacement values - must be an anonymous type.
return string

IsNotNullOrEmpty() public static method

Indicates whether the current string is not null and not an System.String.Empty string.
public static IsNotNullOrEmpty ( this source ) : bool
source this The string to test.
return bool

IsNotNullOrWhiteSpace() public static method

Indicates whether the current string is not null, not empty, and does not consist only of white-space characters.
public static IsNotNullOrWhiteSpace ( this source ) : bool
source this The string to test.
return bool

IsNullOrEmpty() public static method

Indicates whether the current string is null or an System.String.Empty string.
public static IsNullOrEmpty ( this source ) : bool
source this The string to test.
return bool

IsNullOrWhiteSpace() public static method

Indicates whether the current string is null, empty, or consists only of white-space characters.
public static IsNullOrWhiteSpace ( this source ) : bool
source this The string to test.
return bool

PadNumber() public static method

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.
is less than zero.
public static PadNumber ( this source, int maxNumberToMatch, char paddingChar = '0' ) : string
source this The source.
maxNumberToMatch int The maximum number to match.
paddingChar char A Unicode padding character.
return string

PadNumber() public static method

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.
is less than zero.
public static PadNumber ( this source, long maxNumberToMatch, char paddingChar = '0' ) : string
source this The source.
maxNumberToMatch long The maximum number to match.
paddingChar char A Unicode padding character.
return string

PadNumber() public static method

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a total length equal to that of the length of the maximum number to match.
public static PadNumber ( this source, uint maxNumberToMatch, char paddingChar = '0' ) : string
source this The source.
maxNumberToMatch uint The maximum number to match.
paddingChar char A Unicode padding character.
return string

Reverse() public static method

Reverses the sequence of the characters in the entire string.
is null.
public static Reverse ( this source ) : string
source this The source.
return string

ToInt32() public static method

Converts the current string representation of a number to its 32-bit signed integer equivalent.
is null. is not in the correct format. represents a number less than or greater than .
public static ToInt32 ( this source ) : int
source this The source containing a number to convert.
return int

Trim() public static method

Removes all leading and trailing occurrences of the given string from the current String object.
is null or empty.
public static Trim ( this source, string trim ) : string
source this The source.
trim string The string to remove.
return string