Utils_String Class |
Namespace: MicaSystems.Utils
public static class Utils_String
The Utils_String type exposes the following members.
Name | Description | |
---|---|---|
AddLine(String, String) |
Returns a string equal to : str + carrage return char + new line char + newLine.
| |
AddLine(String, String, String) |
Returns a string equal to : str + carrage return char + new line char + newLine formatted with parameters.
| |
AddLines |
Returns a string containing all parameters separated with carrage return and new line characters
| |
Append |
Appends multiple strings to the end of the builder instance.
| |
AppendLine |
Appends multiple strings followed by the default line terminator to the end of the builder instance.
| |
AppendList |
Appends multiple strings to the end of the builder instance.
| |
CamelCaseToDisplay |
Converts a Camel case text to a displayable text. E.g. "HelloWorld" becomes "Hello world".
| |
Compare |
Compares two arrays of bytes.
Note : this method uses SequenceEqual method but will not fail if one or both arrays are null. | |
Contains |
Checks if a string contains another string. (Uses s.IndexOf method)
| |
ContainsAny |
Checks if a string contains any of the specified strings.
| |
ContainsExact | This method will split the string into multiple parts using given separators. | |
ContainsNewLine |
Checks if the string contains a new line character '\n'.
| |
ConvertToEnumT(String) |
Returns an enum value obtained from a matching text.
| |
ConvertToEnumT(String, T) |
Returns an enum value obtained from a matching text.
| |
CreateLines |
Returns a string containing all parameters separated with carrage return and new line characters
| |
CutOrPadRight |
Cuts the given string if it's too long or fill it with spaces.
| |
DecryptString |
Fast aes decryption method. CicpherText should contain IV and cipher in base64 encoding.
Do not use for heavy work because of memory implications.
Key must be between 128 and 256 bits long.
| |
DeserializeJson(String, Type) |
Deserializes an object using a DataContractJsonSerializer.
| |
DeserializeJsonT(String) |
Deserializes an object using a DataContractJsonSerializer.
| |
DeserializeJsonT(String, DataContractJsonSerializerSettings) |
Deserializes an object using a DataContractJsonSerializer.
| |
DeserializeJsonT(String, Type, ListType) |
Deserializes an object using a DataContractJsonSerializer.
| |
EncryptString |
Fast aes encryption method. Returns IV and cipherText in base64 encoding. Do not use for heavy work because of memory implications.
Key must be between 128 and 256 bits long.
| |
EnsureEnd |
Ensures that the string ends with a specific string.
| |
EnsureStart |
Ensures that the string starts with a specific string.
| |
FastConcat |
Concatanates all strings in a single string.
| |
FindParameters | Gets all parameter names using {PARAM} format. Example : "Move workflow {title} to state {state}." will return title and state. | |
FirstLetterToLower |
Converts the first letter of this string to lowercase.
| |
FirstLetterToUpper |
Converts the first letter of this string to uppercase.
| |
Generate |
Creates a new string equal to a text repeated [number] times.
| |
GetAllIndexes |
Finds all occurences of a text inside another and return corresponding indexes.
| |
GetBoolean |
Tries to convert a text to Boolean. If not converted, will return false.
| |
GetBytes |
Converts a string to an array of bytes.
Note : This method uses System.Buffer.BlockCopy. | |
GetCronDay |
Gets the day formatted text : uppercased three first letters.
| |
GetDate |
Tries to convert a text to DateTime. If not converted, will return DateTime.MinValue.
| |
GetDateTimeOffset(String) |
Tries to convert a text to DateTimeOffset. If not converted, will return DateTimeOffset.MinValue.
| |
GetDateTimeOffset(String, CultureInfo) |
Tries to convert a text to DateTimeOffset. If not converted, will return DateTimeOffset.MinValue.
| |
GetDateTimeOffset(String, String, CultureInfo) |
Tries to convert a text to DateTimeOffset using a specific format.
If not converted, will return DateTimeOffset.MinValue. | |
GetDecimal(String) |
Tries to convert a text to decimal. If not converted, will return 0.
| |
GetDecimal(String, CultureInfo) |
Tries to convert a text to decimal using the given culture. If not converted, will return 0.
| |
GetDouble(String) |
Tries to convert a text to double. If not converted, will return 0.
| |
GetDouble(String, CultureInfo) |
Tries to convert a text to double using the given culture. If not converted, will return 0.
| |
GetFloat(String) |
Tries to convert a text to float. If not converted, will return 0.
| |
GetFloat(String, CultureInfo) |
Tries to convert a text to float using the given culture. If not converted, will return 0.
| |
GetGuid |
Tries to convert a text to Guid. If not converted, will return Guid.Empty.
| |
GetHash |
Gets a hash for the specified string.
| |
GetHashString |
Gets a hash for the specified string.
| |
GetInt |
Tries to convert a text to int. If not converted, will return 0.
| |
GetLong |
Tries to convert a text to long. If not converted, will return 0.
| |
GetString |
Converts an array of bytes to a string.
Note : This method uses System.Buffer.BlockCopy. | |
GetStringWithMissingCR |
If this string does not contain carrage return \r,
xill replace all new line \n occurences by \r\n.
| |
HtmlAttributeEncode |
Equivalent to HttpUtility.HtmlAttributeEncode()
| |
HtmlEncode |
Equivalent to HttpUtility.HtmlEncode()
| |
IEquals |
Checks if two strings are equal, ignoring case.
| |
Insert |
Inserts multiple strings into the builder instance at the specified character position.
| |
InsertFormat |
Inserts a single (formatted) string into the builder instance at the specified character position.
| |
IsNotNullOrEmpty |
Checks if a string is NOT null or empty. Same behavior as !String.IsNullOrEmpty(s) method.
| |
IsNullOrEmpty |
Checks if a string is null or empty. Same behavior as String.IsNullOrEmpty(s) method.
| |
LimitChars |
Limits the length of this string to the given limit. Will not throw if it was not necessary.
| |
NotEmptyOr |
Returns original text if not null or empty, otherwise return alternative text sent in parameters.
| |
NumberOfOccurences(String, Char) | Returns the number of occurences of a text inside another text. Faster than other overload. Use this method if the search text is only a char. | |
NumberOfOccurences(String, String) |
Returns the number of occurences of a text inside another text.
| |
ParseIndex |
Returns an integer found between a char separator and the end of given string value.
| |
RemoveAccent |
Replaces a, e, i, o, u, y letters with accent by the corresponding
character without accent.
| |
RemoveBrackets |
Removes the characters '[' and ']' from this string.
| |
RemoveDiacritics | Diacritic explantion from Wikipedia. Some diacritical marks, such as the grave and acute, but not the cedilla, are often called accents. Diacritical marks may appear above or below a letter, or in some other position such as within the letter or between two letters. | |
RemoveStrings |
Removes all occurences of given texts.
| |
Replace |
Replaces all occurrences of a string by another string
in this string with the possibility to ignore case.
| |
SerializeJson(Object) |
Serializes an object using a DataContractJsonSerializer.
| |
SerializeJson(Object, ListType) |
Serializes an object using a DataContractJsonSerializer.
| |
SerializeJson(Object, DataContractJsonSerializerSettings) |
Serializes an object using a DataContractJsonSerializer.
| |
SmartSplit(String, ListString) |
Splits a string into multiple parts using a list of separators.
| |
SmartSplit(String, String) |
Splits a string into multiple parts using a given separator.
| |
SplitToPair |
Splits a string into a apair of strings.
| |
SplitWords |
Tokenizes the specified string. (words are splitted before every uppercase letter)
| |
StringToListT |
Deserializes a serialized List.
| |
ToCamelCase |
Converts a text to camel case. E.g. "hello world" becomes "helloWorld".
| |
ToKebabCase |
Converts a text to kebab case. E.g. "HelloWorld" becomes "-hello-world".
| |
ToLower |
Converts this string to lowercase and remove accents if specified.
| |
ToPascalCase |
Converts a text to pascal case. E.g. "hello world" becomes "HelloWorld".
| |
ToSentenceCase |
Converts a text to a displayable text. E.g. "HelloWorld" becomes "Hello world".
| |
ToSnakeCase |
Converts a text to snake case. E.g. "HelloWorld" becomes "hello-world".
| |
ToTitleCase |
Converts a text to a displayable text. E.g. "HelloWorld" becomes "Hello World".
| |
TrimEnd |
Removes all occurences of a string at the end of this string.
| |
TrimStart |
Removes all occurences of a string at the begining of this string.
| |
TryConvertToEnumT(String) |
Tries to obtain an enum value from a matching text.
| |
TryConvertToEnumT(String, Boolean) |
Tries to obtain an enum value from a matching text.
| |
UnTrim(String, Int32) |
Extends the string to the specified size using spaces.
| |
UnTrim(String, Int32, String) |
Extends the string to the specified size using the given text.
| |
UrlTotalEncode |
Encodes url in UTF8 format. Same behavior as HttpUtility.UrlEncode method.
|