Class StringExtensions
Inherited Members
Namespace: GitCredentialManager
Assembly: Algenta.Colectica.Repository.Client.dll
Syntax
public static class StringExtensions
Methods
IsFalsey(string)
Check if the string is considered to be 'falsey' (a value considered equivalent to 'false').
Declaration
public static bool IsFalsey(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | String value to check. |
Returns
Type | Description |
---|---|
bool | True if the value is 'falsey', false otherwise. |
Remarks
Git considers several different values to be equivalent to 'false'; we try to be consistent with this behavior.
See the following Git documentation for a list of values considered to be equivalent to 'false': https://git-scm.com/docs/git-config#git-config-booleanIsTruthy(string)
Check if the string is considered to be 'truthy' (a value considered equivalent to 'true').
Declaration
public static bool IsTruthy(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | String value to check. |
Returns
Type | Description |
---|---|
bool | True if the value is 'truthy', false otherwise. |
Remarks
Git considers several different values to be equivalent to 'true'; we try to be consistent with this behavior.
See the following Git documentation for a list of values considered to be equivalent to 'true': https://git-scm.com/docs/git-config#git-config-booleanToBooleany(string)
Check if the string is considered to be either 'truthy' or 'falsey' (values considered equivalent to 'true' and 'false').
Declaration
public static bool? ToBooleany(this string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | String value to check. |
Returns
Type | Description |
---|---|
bool? | True if the value is 'truthy', 'false' if the value is 'falsey', null otherwise. |
Remarks
Git considers several different values to be equivalent to 'true' and 'false'; we try to be consistent with this behavior.
See the following Git documentation for a list of values considered to be equivalent to 'true' and 'false': https://git-scm.com/docs/git-config#git-config-booleanToBooleanyOrDefault(string, bool)
Check if the string is considered to be either 'truthy' or 'falsey' (values considered equivalent to 'true' and 'false').
Declaration
public static bool ToBooleanyOrDefault(this string str, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
string | str | String value to check. |
bool | defaultValue | Default value to return if the string is neither 'truthy', 'falsey', or has not been set. |
Returns
Type | Description |
---|---|
bool | True if the value is 'truthy', 'false' if the value is 'falsey', |
Remarks
Git considers several different values to be equivalent to 'true' and 'false'; we try to be consistent with this behavior.
See the following Git documentation for a list of values considered to be equivalent to 'true' and 'false': https://git-scm.com/docs/git-config#git-config-booleanTrimMiddle(string, string, StringComparison)
Trim the matching value from the middle of the string.
Declaration
public static string TrimMiddle(this string str, string value, StringComparison comparisonType = StringComparison.Ordinal)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to trim. |
string | value | String to locate and remove. |
StringComparison | comparisonType | Comparison rule for locating the string. |
Returns
Type | Description |
---|---|
string | Trimmed string. |
TrimUntilIndexOf(string, char)
Trim all characters at the start of the string until the first index of the given character, also removing the indexed character.
Declaration
public static string TrimUntilIndexOf(this string str, char c)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to trim. |
char | c | Character to locate the index of. |
Returns
Type | Description |
---|---|
string | Trimmed string. |
TrimUntilIndexOf(string, string, StringComparison)
Trim all characters at the start of the string until the first index of the given string, also removing the indexed character.
Declaration
public static string TrimUntilIndexOf(this string str, string value, StringComparison comparisonType = StringComparison.Ordinal)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to trim. |
string | value | String to locate the index of. |
StringComparison | comparisonType | Comparison rule for locating the string. |
Returns
Type | Description |
---|---|
string | Trimmed string. |
TrimUntilLastIndexOf(string, char)
Trim all characters at the start of the string until the last index of the given character, also removing the indexed character.
Declaration
public static string TrimUntilLastIndexOf(this string str, char c)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to trim. |
char | c | Character to locate the index of. |
Returns
Type | Description |
---|---|
string | Trimmed string. |
TrimUntilLastIndexOf(string, string, StringComparison)
Trim all characters at the start of the string until the last index of the given string, also removing the indexed character.
Declaration
public static string TrimUntilLastIndexOf(this string str, string value, StringComparison comparisonType = StringComparison.Ordinal)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to trim. |
string | value | String to locate the index of. |
StringComparison | comparisonType | Comparison rule for locating the string. |
Returns
Type | Description |
---|---|
string | Trimmed string. |
TruncateFromIndexOf(string, char)
Truncate the string from the first index of the given character, also removing the indexed character.
Declaration
public static string TruncateFromIndexOf(this string str, char c)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to truncate. |
char | c | Character to locate the index of. |
Returns
Type | Description |
---|---|
string | Truncated string. |
TruncateFromLastIndexOf(string, char)
Truncate the string from the last index of the given character, also removing the indexed character.
Declaration
public static string TruncateFromLastIndexOf(this string str, char c)
Parameters
Type | Name | Description |
---|---|---|
string | str | String to truncate. |
char | c | Character to locate the index of. |
Returns
Type | Description |
---|---|
string | Truncated string. |