C# Class ToolBelt.StringUtility

Groups a set of useful string manipulation and validation methods.
ファイルを表示 Open project: jlyonsmith/ToolBelt

Public Methods

Method Description
ConvertEmptyToNull ( string value ) : string

Converts an empty string ("") to .

ConvertNullToEmpty ( string value ) : string

Converts to an empty string.

CultureFormat ( this format ) : string

Format a string using the current culture. Use for strings returned to user.

InvariantFormat ( this format ) : string

Format a string using the invariant culture. Use for persisted strings not returned to user.

Join ( string separator, IList value ) : string

Concatenates a specified separator string between each element of a specified list, yielding a single concatenated string.

For example if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", the method returns "apple, orange, grape, pear".

If separator is , an empty string (string.Empty) is used instead.

ReplaceTags ( this source, string tagPrefix, string tagSuffix, IDictionary tagDictionary, TaggedStringOptions flags = TaggedStringOptions.RemoveUnknownTags ) : string

This method searches for each occurrence of a tagged variable in source and replaces it with the value from the a dictionary subs. Comparisons are done case insensitively.

WordWrap ( this text, int lineLength ) : string[]

Breaks a string on word boundaries, to the given lineLength. Only space characters are considered when breaking up lines. Embedded Environment.NewLine sequences will break a line and are not included in the resulting output. Each line is broken after the first whitespace after the last word on the line, so all space characters are preserved in the resulting output.

Method Details

ConvertEmptyToNull() public static method

Converts an empty string ("") to .
public static ConvertEmptyToNull ( string value ) : string
value string The value to convert.
return string

ConvertNullToEmpty() public static method

Converts to an empty string.
public static ConvertNullToEmpty ( string value ) : string
value string The value to convert.
return string

CultureFormat() public static method

Format a string using the current culture. Use for strings returned to user.
public static CultureFormat ( this format ) : string
format this
return string

InvariantFormat() public static method

Format a string using the invariant culture. Use for persisted strings not returned to user.
public static InvariantFormat ( this format ) : string
format this
return string

Join() public static method

Concatenates a specified separator string between each element of a specified list, yielding a single concatenated string.

For example if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", the method returns "apple, orange, grape, pear".

If separator is , an empty string (string.Empty) is used instead.

public static Join ( string separator, IList value ) : string
separator string A .
value IList A string collection.
return string

ReplaceTags() public static method

This method searches for each occurrence of a tagged variable in source and replaces it with the value from the a dictionary subs. Comparisons are done case insensitively.
public static ReplaceTags ( this source, string tagPrefix, string tagSuffix, IDictionary tagDictionary, TaggedStringOptions flags = TaggedStringOptions.RemoveUnknownTags ) : string
source this String containing tagged entities
tagPrefix string The tag prefix
tagSuffix string The tag suffix
tagDictionary IDictionary
flags TaggedStringOptions for the replace operation
return string

WordWrap() public static method

Breaks a string on word boundaries, to the given lineLength. Only space characters are considered when breaking up lines. Embedded Environment.NewLine sequences will break a line and are not included in the resulting output. Each line is broken after the first whitespace after the last word on the line, so all space characters are preserved in the resulting output.
public static WordWrap ( this text, int lineLength ) : string[]
text this The text to break up.
lineLength int The maximum length of a line
return string[]