Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Extensions.StringExtensions Class Reference

String custom methods More...

Static Public Member Functions

static bool IsEqual (this string s1, string s2, StringComparison comparison=StringComparison.CurrentCultureIgnoreCase)
 Performs check against any 2 strings (accounts for null, and trims extra whitespace) More...
 
static bool IsLessThan (this string left, string right, StringComparison comparison=StringComparison.CurrentCultureIgnoreCase)
 < operator More...
 
static bool IsLessThanOrEqual (this string left, string right, StringComparison comparison=StringComparison.CurrentCultureIgnoreCase)
 <= operator More...
 
static bool IsMoreThan (this string left, string right, StringComparison comparison=StringComparison.CurrentCultureIgnoreCase)
 > operator More...
 
static bool IsMoreThanOrEqual (this string left, string right, StringComparison comparison=StringComparison.CurrentCultureIgnoreCase)
 >= operator More...
 
static bool Like (this string str, string contains, StringComparison comp=StringComparison.CurrentCultureIgnoreCase)
 Performs a "like" operation (contains, but case insensitive) More...
 
static string RemoveAfter (this string s, char delimiter, bool keepDelimiter=true)
 Removes everything after the given delimiter More...
 
static string RemoveBefore (this string s, char delimiter, bool keepDelimiter=true)
 Removes everything before the given delimiter More...
 
static string KeepBefore (this string s, char delimiter)
 Keeps everything before the given delimiter More...
 
static string KeepAfter (this string s, char delimiter)
 Keeps everything after the given delimiter More...
 
static string Trimmed (this string s)
 Obtains a usable string from a post/request/database, etc (will be not null and trimmed - possibly "") More...
 
static string RemoveSpecialChars (this string str)
 This removes all special characters from the string More...
 
static string Shorten (this string s, int length)
 Shortens a string to the desired length More...
 
static string ShortenWithEllipses (this string s, int length)
 
static IEnumerable< string > SafeSplit (this string s, string delimiter, StringSplitOptions option=StringSplitOptions.None)
 Splits a string on another string (same as a character split) More...
 
static IEnumerable< string > SafeSplit (this string s, string delimiter, bool removeEmpties)
 Splits a string on another string (same as a character split) More...
 
static IEnumerable< string > SafeSplit (this string s, string delimiter, StringSplitOptions option, bool removeEmpties)
 Splits a string on another string (same as a character split) More...
 
static string Reverse (this string str)
 Reverses a string More...
 
static string Pluralize (this string s)
 Pluralizes a given word (not fully implemented properly, but works) More...
 
static string Capitalize (this string str)
 Capitalizes the first letter in the string More...
 
static string SplitCamelCase (this string s)
 Converts the given string to readable format (spaces in camel casing) More...
 
static string ToHtml (this string str)
 This encodes a user typed string as HTML to be displayed directly onto a Web page More...
 
static string ToCsv (this string str)
 This encodes a string for exporting as a CSV file More...
 
static string ToExcel (this string str)
 This encodes a string for exporting as an excel file More...
 
static string DecodeUri (this string uri)
 Decodes a string that was encoded using javascript's "encodeURIComponent" function More...
 
static string EncodeUri (this string uri)
 Encodes a string so that it will appear as-is when retrieved from the client via the URI More...
 

Detailed Description

String custom methods

Member Function Documentation

◆ Capitalize()

static string Sphyrnidae.Common.Extensions.StringExtensions.Capitalize ( this string  str)
static

Capitalizes the first letter in the string

Parameters
strThe string to be capitalized
Returns
Capitalized string

◆ DecodeUri()

static string Sphyrnidae.Common.Extensions.StringExtensions.DecodeUri ( this string  uri)
static

Decodes a string that was encoded using javascript's "encodeURIComponent" function

Parameters
uriThe string to decode
Returns
The decoded string

◆ EncodeUri()

static string Sphyrnidae.Common.Extensions.StringExtensions.EncodeUri ( this string  uri)
static

Encodes a string so that it will appear as-is when retrieved from the client via the URI

Parameters
uriThe string to encode
Returns
The encoded string

◆ IsEqual()

static bool Sphyrnidae.Common.Extensions.StringExtensions.IsEqual ( this string  s1,
string  s2,
StringComparison  comparison = StringComparison.CurrentCultureIgnoreCase 
)
static

Performs check against any 2 strings (accounts for null, and trims extra whitespace)

Parameters
s1First string
s2Second string
comparisonOptional: Default = CurrentCultureIgnoreCase
Returns
True if they are the same, false if there is a real difference

◆ IsLessThan()

static bool Sphyrnidae.Common.Extensions.StringExtensions.IsLessThan ( this string  left,
string  right,
StringComparison  comparison = StringComparison.CurrentCultureIgnoreCase 
)
static

< operator

Parameters
leftThe left value
rightThe right value
comparisonOptional: Default = CurrentCultureIgnoreCase
Returns
True if the left value is less than the right value (based on comparison/sorting)

◆ IsLessThanOrEqual()

static bool Sphyrnidae.Common.Extensions.StringExtensions.IsLessThanOrEqual ( this string  left,
string  right,
StringComparison  comparison = StringComparison.CurrentCultureIgnoreCase 
)
static

<= operator

Parameters
leftThe left value
rightThe right value
comparisonOptional: Default = CurrentCultureIgnoreCase
Returns
True if the left value is less than or equal to the right value (based on comparison/sorting)

◆ IsMoreThan()

static bool Sphyrnidae.Common.Extensions.StringExtensions.IsMoreThan ( this string  left,
string  right,
StringComparison  comparison = StringComparison.CurrentCultureIgnoreCase 
)
static

> operator

Parameters
leftThe left value
rightThe right value
comparisonOptional: Default = CurrentCultureIgnoreCase
Returns
True if the left value is less than the right value (based on comparison/sorting)

◆ IsMoreThanOrEqual()

static bool Sphyrnidae.Common.Extensions.StringExtensions.IsMoreThanOrEqual ( this string  left,
string  right,
StringComparison  comparison = StringComparison.CurrentCultureIgnoreCase 
)
static

>= operator

Parameters
leftThe left value
rightThe right value
comparisonOptional: Default = CurrentCultureIgnoreCase
Returns
True if the left value is less than the right value (based on comparison/sorting)

◆ KeepAfter()

static string Sphyrnidae.Common.Extensions.StringExtensions.KeepAfter ( this string  s,
char  delimiter 
)
static

Keeps everything after the given delimiter

Parameters
sThe string being manipulated
delimiterWhere to split apart the string
Returns
Everything after the delimiter

◆ KeepBefore()

static string Sphyrnidae.Common.Extensions.StringExtensions.KeepBefore ( this string  s,
char  delimiter 
)
static

Keeps everything before the given delimiter

Parameters
sThe string being manipulated
delimiterWhere to split apart the string
Returns
Everything before the delimiter

◆ Like()

static bool Sphyrnidae.Common.Extensions.StringExtensions.Like ( this string  str,
string  contains,
StringComparison  comp = StringComparison.CurrentCultureIgnoreCase 
)
static

Performs a "like" operation (contains, but case insensitive)

Parameters
strThe original string
containsThe string to check if the original string contains it
compThe comparison to use (Default = CurrentCultureIgnoreCase)
Returns
True if it contains it, false otherwise

◆ Pluralize()

static string Sphyrnidae.Common.Extensions.StringExtensions.Pluralize ( this string  s)
static

Pluralizes a given word (not fully implemented properly, but works)

Parameters
sThe word to be pluralized
Returns
The pluralized word

◆ RemoveAfter()

static string Sphyrnidae.Common.Extensions.StringExtensions.RemoveAfter ( this string  s,
char  delimiter,
bool  keepDelimiter = true 
)
static

Removes everything after the given delimiter

Parameters
sThe string being manipulated
delimiterWhere to split apart the string
keepDelimiterIf you should keep the delimiter, or remove it
Returns
The modified string

◆ RemoveBefore()

static string Sphyrnidae.Common.Extensions.StringExtensions.RemoveBefore ( this string  s,
char  delimiter,
bool  keepDelimiter = true 
)
static

Removes everything before the given delimiter

Parameters
sThe string being manipulated
delimiterWhere to split apart the string
keepDelimiterIf you should keep the delimiter, or remove it
Returns
The modified string

◆ RemoveSpecialChars()

static string Sphyrnidae.Common.Extensions.StringExtensions.RemoveSpecialChars ( this string  str)
static

This removes all special characters from the string

Parameters
strThe original string
Returns
The string without special characters

◆ Reverse()

static string Sphyrnidae.Common.Extensions.StringExtensions.Reverse ( this string  str)
static

Reverses a string

Parameters
strThe original string
Returns
A new string that is reversed

◆ SafeSplit() [1/3]

static IEnumerable<string> Sphyrnidae.Common.Extensions.StringExtensions.SafeSplit ( this string  s,
string  delimiter,
bool  removeEmpties 
)
static

Splits a string on another string (same as a character split)

Parameters
sThe string to split
delimiterThe string which will delimit the original string
removeEmptiesIf empty elements (IsNullOrWhiteSpace) will be removed from the list (default false)
Returns
Listing of all strings split by the delimiter

◆ SafeSplit() [2/3]

static IEnumerable<string> Sphyrnidae.Common.Extensions.StringExtensions.SafeSplit ( this string  s,
string  delimiter,
StringSplitOptions  option,
bool  removeEmpties 
)
static

Splits a string on another string (same as a character split)

Parameters
sThe string to split
delimiterThe string which will delimit the original string
optionHow to split the string (Default no options)
removeEmptiesIf empty elements (IsNullOrWhiteSpace) will be removed from the list (default false)
Returns
Listing of all strings split by the delimiter

◆ SafeSplit() [3/3]

static IEnumerable<string> Sphyrnidae.Common.Extensions.StringExtensions.SafeSplit ( this string  s,
string  delimiter,
StringSplitOptions  option = StringSplitOptions.None 
)
static

Splits a string on another string (same as a character split)

Parameters
sThe string to split
delimiterThe string which will delimit the original string
optionHow to split the string (Default no options)
Returns
Listing of all strings split by the delimiter

◆ Shorten()

static string Sphyrnidae.Common.Extensions.StringExtensions.Shorten ( this string  s,
int  length 
)
static

Shortens a string to the desired length

Parameters
sThe string being manipulated
lengthThe desired length
Returns
The possibly shortened string

◆ ShortenWithEllipses()

static string Sphyrnidae.Common.Extensions.StringExtensions.ShortenWithEllipses ( this string  s,
int  length 
)
static

◆ SplitCamelCase()

static string Sphyrnidae.Common.Extensions.StringExtensions.SplitCamelCase ( this string  s)
static

Converts the given string to readable format (spaces in camel casing)

Parameters
sThe string to work on
Returns
The string with spaces in camel casing

◆ ToCsv()

static string Sphyrnidae.Common.Extensions.StringExtensions.ToCsv ( this string  str)
static

This encodes a string for exporting as a CSV file

Parameters
strThe string to encode
Returns
The encoded string

◆ ToExcel()

static string Sphyrnidae.Common.Extensions.StringExtensions.ToExcel ( this string  str)
static

This encodes a string for exporting as an excel file

Parameters
strThe string to encode
Returns
The encoded string

◆ ToHtml()

static string Sphyrnidae.Common.Extensions.StringExtensions.ToHtml ( this string  str)
static

This encodes a user typed string as HTML to be displayed directly onto a Web page

Parameters
strThe string to encode
Returns
The encoded string

◆ Trimmed()

static string Sphyrnidae.Common.Extensions.StringExtensions.Trimmed ( this string  s)
static

Obtains a usable string from a post/request/database, etc (will be not null and trimmed - possibly "")

Parameters
sThe string being checked
Returns
The not null/trimmed string

The documentation for this class was generated from the following file: