C# Class Crisis.StringFormatter

Class performing various formatting operations on strings based on fixed width characters.
Datei anzeigen Open project: teeknofil/Crisis-Wordlist-Generator Class Usage Examples

Public Methods

Method Description
Align ( string str, int width, Alignment alignment ) : string

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' '), and the ellipsis used will be the string "...". Cropping will be done on the right hand side of the string.

Align ( string str, int width, Alignment alignment, Cropping cropping ) : string

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' '), and the ellipsis used will be the string "...".

Align ( string str, int width, Alignment alignment, Cropping cropping, string ellipsis ) : string

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' ').

Align ( string str, int width, Alignment alignment, Cropping cropping, string ellipsis, char padCharacter ) : string

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

FormatInColumns ( int indent, int columnSpacing ) : string

Formats several fixed width strings into columns of the specified widths, performing word wrapping and alignment as specified.

GetWordCount ( string str ) : int

Retrieves the number of words in the specified string.

A word here is defined as any number (greater than zero) of non-whitespace characters, separated from other words by one or more white space characters.

SplitAtLineBreaks ( string str ) : IIndexed

Splits the specified strings at line breaks, resulting in an indexed collection where each item represents one line of the original string.

This might seem identical to the String.Split method at first, but it is not exactly, since this method recognizes line breaks in the three formats: "\n", "\r" and "\r\n". Note that any newline characters will not be present in the returned collection.

SplitAtLineBreaks ( string str, bool removeEmptyLines ) : IIndexed

Splits the specified strings at line breaks, resulting in an indexed collection where each item represents one line of the original string.

This might seem identical to the String.Split method at first, but it is not exactly, since this method recognizes line breaks in the three formats: "\n", "\r" and "\r\n". Note that any newline characters will not be present in the returned collection.

WordWrap ( string str, int width ) : string

Performs word wrapping on the specified string, making it fit within the specified width.

No padding will be performed on strings that are shorter than the specified width, and each line will be left aligned.

This method uses WordWrappingMethod.Optimal to perform word wrapping.

WordWrap ( string str, int width, WordWrappingMethod method ) : string

Performs word wrapping on the specified string, making it fit within the specified width.

No padding will be performed on strings that are shorter than the specified width, and each line will be left aligned.

WordWrap ( string str, int width, WordWrappingMethod method, Alignment alignment ) : string

Performs word wrapping on the specified string, making it fit within the specified width and additionally aligns each line according to the Alignment specified.

If padding is required, the normal simple white space character (' ') will be used.

WordWrap ( string str, int width, WordWrappingMethod method, Alignment alignment, char padCharacter ) : string

Performs word wrapping on the specified string, making it fit within the specified width and additionally aligns each line according to the Alignment specified.

Method Details

Align() public static method

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' '), and the ellipsis used will be the string "...". Cropping will be done on the right hand side of the string.

was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero. is less than the length of the specified , or, /// the cropping specified is and was less than twice the /// length of the
public static Align ( string str, int width, Alignment alignment ) : string
str string The string to align.
width int The width of the field in characters in which the string should be fitted.
alignment Alignment The aligmnent that will be used for fitting the string in the field in case it is shorter than the specified field width.
return string

Align() public static method

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' '), and the ellipsis used will be the string "...".

was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero. is less than the length of the specified, or, /// the cropping specified is and was less than twice the /// length of the
public static Align ( string str, int width, Alignment alignment, Cropping cropping ) : string
str string The string to align.
width int The width of the field in characters in which the string should be fitted.
alignment Alignment The aligmnent that will be used for fitting the string in the field in case it is shorter than the specified field width.
cropping Cropping The method that will be used for cropping if the string is too wide to fit in the specified width.
return string

Align() public static method

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.

If the string consists of several lines, each line will be aligned according to the specified parameters.

The padding character used will be the normal white space character (' ').

was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero. is less than the length of the specified , or, /// the cropping specified is and was less than twice the /// length of the
public static Align ( string str, int width, Alignment alignment, Cropping cropping, string ellipsis ) : string
str string The string to align.
width int The width of the field in characters in which the string should be fitted.
alignment Alignment The aligmnent that will be used for fitting the string in the field in case it is shorter than the specified field width.
cropping Cropping The method that will be used for cropping if the string is too wide to fit in the specified width.
ellipsis string A string that will be inserted at the cropped side(s) of the string to denote that the string has been cropped.
return string

Align() public static method

Aligns the specified string within a field of the desired width, cropping it if it doesn't fit, and expanding it otherwise.
If the string consists of several lines, each line will be aligned according to the specified parameters.
was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero. is less than the length of the specified , or, /// the cropping specified is and was less than twice the /// length of the
public static Align ( string str, int width, Alignment alignment, Cropping cropping, string ellipsis, char padCharacter ) : string
str string The string to align.
width int The width of the field in characters in which the string should be fitted.
alignment Alignment The aligmnent that will be used for fitting the string in the field in case it is shorter than the specified field width.
cropping Cropping The method that will be used for cropping if the string is too wide to fit in the specified width.
ellipsis string A string that will be inserted at the cropped side(s) of the string to denote that the string has been cropped.
padCharacter char The character that will be used for padding the string in case it is shorter than the specified field width.
return string

FormatInColumns() public static method

Formats several fixed width strings into columns of the specified widths, performing word wrapping and alignment as specified.
A for a column was a null reference (Nothing in Visual Basic) The specified for a column was less than, or equal to zero. was less than zero, or, was less than /// zero, or, no columns were specified.
public static FormatInColumns ( int indent, int columnSpacing ) : string
indent int The indentation (number of white space characters) to use before the first column.
columnSpacing int The spacing to use in between columns.
return string

GetWordCount() public static method

Retrieves the number of words in the specified string.
A word here is defined as any number (greater than zero) of non-whitespace characters, separated from other words by one or more white space characters.
was a null reference (Nothing in Visual Basic)
public static GetWordCount ( string str ) : int
str string The string in which to count the words.
return int

SplitAtLineBreaks() public static method

Splits the specified strings at line breaks, resulting in an indexed collection where each item represents one line of the original string.
This might seem identical to the String.Split method at first, but it is not exactly, since this method recognizes line breaks in the three formats: "\n", "\r" and "\r\n". Note that any newline characters will not be present in the returned collection.
public static SplitAtLineBreaks ( string str ) : IIndexed
str string The string to split.
return IIndexed

SplitAtLineBreaks() public static method

Splits the specified strings at line breaks, resulting in an indexed collection where each item represents one line of the original string.
This might seem identical to the String.Split method at first, but it is not exactly, since this method recognizes line breaks in the three formats: "\n", "\r" and "\r\n". Note that any newline characters will not be present in the returned collection.
public static SplitAtLineBreaks ( string str, bool removeEmptyLines ) : IIndexed
str string The string to split.
removeEmptyLines bool if set to true any empty lines will be removed from the resulting collection.
return IIndexed

WordWrap() public static method

Performs word wrapping on the specified string, making it fit within the specified width.

No padding will be performed on strings that are shorter than the specified width, and each line will be left aligned.

This method uses WordWrappingMethod.Optimal to perform word wrapping.

was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero.
public static WordWrap ( string str, int width ) : string
str string The string to word wrap.
width int The width of the field in which to fit the string.
return string

WordWrap() public static method

Performs word wrapping on the specified string, making it fit within the specified width.
No padding will be performed on strings that are shorter than the specified width, and each line will be left aligned.
was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero.
public static WordWrap ( string str, int width, WordWrappingMethod method ) : string
str string The string to word wrap.
width int The width of the field in which to fit the string.
method WordWrappingMethod The method to use for word wrapping.
return string

WordWrap() public static method

Performs word wrapping on the specified string, making it fit within the specified width and additionally aligns each line according to the Alignment specified.
If padding is required, the normal simple white space character (' ') will be used.
was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero.
public static WordWrap ( string str, int width, WordWrappingMethod method, Alignment alignment ) : string
str string The string to word wrap and align.
width int The width of the field in which to fit the string.
method WordWrappingMethod The method to use for word wrapping.
alignment Alignment The alignment to use for each line of the resulting string.
return string

WordWrap() public static method

Performs word wrapping on the specified string, making it fit within the specified width and additionally aligns each line according to the Alignment specified.
was a null reference (Nothing in Visual Basic) The specified was less than, or equal to zero.
public static WordWrap ( string str, int width, WordWrappingMethod method, Alignment alignment, char padCharacter ) : string
str string The string to word wrap and align.
width int The width of the field in which to fit the string.
method WordWrappingMethod The method to use for word wrapping.
alignment Alignment The alignment to use for each line of the resulting string.
padCharacter char The character to use for padding lines that are shorter than the specified width.
return string