C# Class BudgetAnalyser.Engine.StringExtension

An extension class for string.
Exibir arquivo Open project: Benrnz/BudgetAnalyser

Public Methods

Method Description
AnOrA ( this instance, bool properCase = false ) : string

Returns the appropriate 'An' or 'A' prefix for the given string. The given string is not included in the return text.

IsNothing ( this instance ) : bool

Returns true if the string is null, whitespace or empty. Equivelant to IsNullOrWhiteSpace

IsSomething ( this instance ) : bool

Returns true if the string is not null, not whitespace, and not empty. The direct opporsite of IsNothing

SplitLines ( this instance, int numberOfLines ) : string[]

An extension to the string.Split(char[]) method. This method splits at new line characters, trims off trailing whitespace, and returns the specified number of lines.

TrimEndSafely ( this instance ) : string

Trims the end of a string safely. If the string is null, null is returned.

Truncate ( this instance, int truncateToLength, bool useEllipses = false ) : string

Truncates the right of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.

TruncateLeft ( this instance, int truncateToLength, bool useEllipses = false ) : string

Truncates the left of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.

Method Details

AnOrA() public static method

Returns the appropriate 'An' or 'A' prefix for the given string. The given string is not included in the return text.
public static AnOrA ( this instance, bool properCase = false ) : string
instance this The string to determine the prefix for.
properCase bool A boolean to indicate if the prefix should be proper-cased or not.
return string

IsNothing() public static method

Returns true if the string is null, whitespace or empty. Equivelant to IsNullOrWhiteSpace
public static IsNothing ( this instance ) : bool
instance this
return bool

IsSomething() public static method

Returns true if the string is not null, not whitespace, and not empty. The direct opporsite of IsNothing
public static IsSomething ( this instance ) : bool
instance this
return bool

SplitLines() public static method

An extension to the string.Split(char[]) method. This method splits at new line characters, trims off trailing whitespace, and returns the specified number of lines.
public static SplitLines ( this instance, int numberOfLines ) : string[]
instance this
numberOfLines int
return string[]

TrimEndSafely() public static method

Trims the end of a string safely. If the string is null, null is returned.
public static TrimEndSafely ( this instance ) : string
instance this
return string

Truncate() public static method

Truncates the right of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.
public static Truncate ( this instance, int truncateToLength, bool useEllipses = false ) : string
instance this
truncateToLength int
useEllipses bool
return string

TruncateLeft() public static method

Truncates the left of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.
public static TruncateLeft ( this instance, int truncateToLength, bool useEllipses = false ) : string
instance this
truncateToLength int
useEllipses bool
return string