C# Class SpeakFriend.Utilities.StringExtension

Show file Open project: teamaton/speak-lib

Public Methods

Method Description
EnsureEndsNotWith ( this value, string suffix ) : string

Returns a new string which is guaranteed not to end with the given suffix. If the suffix is already missing, the same string is returned.

EnsureEndsNotWith ( this value, string suffix, bool ignoreCase ) : string
EnsureEndsWith ( this value, string suffix ) : string

Returns a new string which is guaranteed to end with the given suffix. If the suffix is already present, the same string is returned.

EnsureEndsWith ( this value, string suffix, StringEnsureOptions options ) : string
EnsureStartsNotWith ( this value, string prefix ) : string

Returns a new string which is guaranteed not to begin with the given prefix. If the prefix is already missing, the same string is returned.

EnsureStartsWith ( this value, string prefix ) : string

Returns a new string which is guaranteed to begin with the given prefix. If the prefix is already present, the same string is returned.

EnsureStartsWith ( this value, string prefix, StringEnsureOptions options ) : string
Indent ( this value, int width ) : string
IsEmail ( this text ) : bool
IsNumeric ( this value ) : bool
IsUri ( this uri ) : bool
JoinNonEmpty ( this values, string separator ) : string
ToDate ( this dateText ) : DateTime?
ToInt ( this value ) : int
ToInt32 ( this value ) : int
Truncate ( this text, int maxLength ) : string

Truncates the string to a specified length and replace the truncated to a ...

Truncate ( this text, int maxLength, string suffix ) : string

Truncates the string to a specified length and replaces the truncated to a ...

WordWrap ( this text, int maxLineLength ) : List

Return a list of wrapped lines

Wrap ( this text, int maxLineLength ) : string

Returns the given text with lines separated by Environment.NewLine and a maximum length of maxLineLength. Uses WordWrap internally.

Method Details

EnsureEndsNotWith() public static method

Returns a new string which is guaranteed not to end with the given suffix. If the suffix is already missing, the same string is returned.
public static EnsureEndsNotWith ( this value, string suffix ) : string
value this
suffix string
return string

EnsureEndsNotWith() public static method

public static EnsureEndsNotWith ( this value, string suffix, bool ignoreCase ) : string
value this
suffix string
ignoreCase bool
return string

EnsureEndsWith() public static method

Returns a new string which is guaranteed to end with the given suffix. If the suffix is already present, the same string is returned.
public static EnsureEndsWith ( this value, string suffix ) : string
value this
suffix string
return string

EnsureEndsWith() public static method

public static EnsureEndsWith ( this value, string suffix, StringEnsureOptions options ) : string
value this
suffix string
options StringEnsureOptions
return string

EnsureStartsNotWith() public static method

Returns a new string which is guaranteed not to begin with the given prefix. If the prefix is already missing, the same string is returned.
public static EnsureStartsNotWith ( this value, string prefix ) : string
value this
prefix string
return string

EnsureStartsWith() public static method

Returns a new string which is guaranteed to begin with the given prefix. If the prefix is already present, the same string is returned.
public static EnsureStartsWith ( this value, string prefix ) : string
value this
prefix string
return string

EnsureStartsWith() public static method

public static EnsureStartsWith ( this value, string prefix, StringEnsureOptions options ) : string
value this
prefix string
options StringEnsureOptions
return string

Indent() public static method

public static Indent ( this value, int width ) : string
value this
width int
return string

IsEmail() public static method

public static IsEmail ( this text ) : bool
text this
return bool

IsNumeric() public static method

public static IsNumeric ( this value ) : bool
value this
return bool

IsUri() public static method

public static IsUri ( this uri ) : bool
uri this
return bool

JoinNonEmpty() public static method

public static JoinNonEmpty ( this values, string separator ) : string
values this
separator string
return string

ToDate() public static method

public static ToDate ( this dateText ) : DateTime?
dateText this
return DateTime?

ToInt() public static method

public static ToInt ( this value ) : int
value this
return int

ToInt32() public static method

public static ToInt32 ( this value ) : int
value this
return int

Truncate() public static method

Truncates the string to a specified length and replace the truncated to a ...
public static Truncate ( this text, int maxLength ) : string
text this string that will be truncated
maxLength int total length of characters to maintain before the truncate happens
return string

Truncate() public static method

Truncates the string to a specified length and replaces the truncated to a ...
public static Truncate ( this text, int maxLength, string suffix ) : string
text this string that will be truncated
maxLength int total length of characters to maintain before the truncate happens
suffix string
return string

WordWrap() public static method

Return a list of wrapped lines
public static WordWrap ( this text, int maxLineLength ) : List
text this
maxLineLength int
return List

Wrap() public static method

Returns the given text with lines separated by Environment.NewLine and a maximum length of maxLineLength. Uses WordWrap internally.
public static Wrap ( this text, int maxLineLength ) : string
text this
maxLineLength int
return string