Class StringExtensions
- Namespace
- GroupeIsa.Neos.Shared.Extensions
- Assembly
- GroupeIsa.Neos.Shared.dll
Extensions methods of the type string.
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
HasNoLeadingAndTrailingWhiteSpace(string?)
Indicates whether the string has no leading and trailing whitespace.
public static bool HasNoLeadingAndTrailingWhiteSpace(this string? source)
Parameters
sourcestringA string.
Returns
- bool
True if the string has no leading and trailing whitespace; otherwise, false.
HasNoLeadingWhiteSpace(string?)
Indicates whether the string has no leading whitespace.
public static bool HasNoLeadingWhiteSpace(this string? source)
Parameters
sourcestringA string.
Returns
- bool
True if the string has no leading whitespace; otherwise, false.
HasNoTrailingWhiteSpace(string?)
Indicates whether the string has no trailing whitespace.
public static bool HasNoTrailingWhiteSpace(this string? source)
Parameters
sourcestringA string.
Returns
- bool
True if the string has no trailing whitespace; otherwise, false.
HasNoWhiteSpace(string?)
Indicates whether the string has no whitespace.
public static bool HasNoWhiteSpace(this string? source)
Parameters
sourcestringA string.
Returns
- bool
True if the string has no whitespace; otherwise, false.
IsCamelCase(string)
Indicates whether the string is in camel case.
public static bool IsCamelCase(this string source)
Parameters
sourcestringA string.
Returns
- bool
True if the string is in camel case; otherwise, false.
IsLower(string)
Indicates whether the string is lowercase.
public static bool IsLower(this string source)
Parameters
sourcestringA string.
Returns
- bool
True if the string is lowercase; otherwise, false.
Remarks
Consider string to be lowercase if it has no uppercase letters.
IsPascalCase(string)
Indicates whether the string is in pascal case.
public static bool IsPascalCase(this string source)
Parameters
sourcestringA string.
Returns
- bool
True if the string is in pascal case; otherwise, false.
IsUpper(string)
Indicates whether the string is uppercase.
public static bool IsUpper(this string source)
Parameters
sourcestringA string.
Returns
- bool
True if the string is uppercase; otherwise, false.
Remarks
Consider string to be uppercase if it has no lowercase letters.
NormalizeToUpper(string?)
Normalizes a string by removing diacritics and converting it to uppercase.
public static string? NormalizeToUpper(this string? text)
Parameters
textstringThe source text.
Returns
- string
The normalized text.
SplitLines(string)
Splits string into lines regardless of the newline character (CRLF, LF, CR).
public static string[] SplitLines(this string source)
Parameters
sourcestringThe string to split into lines.
Returns
- string[]
The lines.
ToCamelCase(string)
Converts a string to camelCase.
public static string ToCamelCase(this string source)
Parameters
sourcestringA string.
Returns
- string
The changed string.
Remarks
Same implementation as Newtonsoft.JSON in order to have the same output when generating JSON or using this method. See https://github.com/JamesNK/Newtonsoft.Json/blob/666d9760719e5ec5b2a50046f7dbd6a1267c01c6/Src/Newtonsoft.Json/Utilities/StringUtils.cs#L155. "Entity" becomes "entity". "TwoWords" becomes "twoWords". "UIView" becomes "uiView". "Entity.Name" becomes "entity.name".
ToCapitalizeFirstLetter(string)
Capitalizes the first letter of the specified string.
public static string ToCapitalizeFirstLetter(this string source)
Parameters
sourcestringA string.
Returns
- string
The changed string.
ToKebabCase(string)
Converts a string to kebab-case.
public static string ToKebabCase(this string source)
Parameters
sourcestringString to convert.
Returns
- string
Converted string.
ToLocalizableString(string, char, char, char)
Converts to a localizable string a list of strings each representing a key-value pair that are concatenated using a delimiter character.
[SuppressMessage("Critical Code Smell", "S3776:Cognitive Complexity of methods should not be too high", Justification = "Local functions are taken into account when calculating complexity.")]
public static LocalizableString ToLocalizableString(this string source, char keyValueDelimiter, char delimiter, char escape = '\\')
Parameters
sourcestringList of concatenated key-value pair strings joined by a delimiter character. This format can be obtained when using ToString(IEnumerable<string>, char, char).
keyValueDelimitercharCharacter delimiting a key-value pair.
delimitercharCharacter delimiting key-value pair string.
escapecharEscape character.
Returns
- LocalizableString
Unescaped, split strings.
ToPascalCase(string)
Converts a string to PascalCase.
public static string ToPascalCase(this string source)
Parameters
sourcestringA string.
Returns
- string
The changed string.
ToString(IEnumerable<string>, char, char)
Joins multiple strings using a delimitation character and escapes any occurrence of the delimitation character in said strings by using an escape character.
public static string ToString(this IEnumerable<string> strings, char delimiter, char escape = '\\')
Parameters
stringsIEnumerable<string>Strings to join.
delimitercharDelimiter character.
escapecharEscape character.
Returns
- string
Joined string.
ToStringArray(string, char, char)
Split strings delimited strings, respecting if the delimiter characters is escaped.
public static string[] ToStringArray(this string source, char delimiter, char escape = '\\')
Parameters
sourcestringJoined string from ToString(IEnumerable<string>, char, char).
delimitercharDelimiter character.
escapecharEscape character.
Returns
- string[]
Unescaped, split strings.