-
-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,28 +185,35 @@ internal static bool ContainsExact(this string text, string value) | |
#else | ||
return text.Contains(value, StringComparison.Ordinal); | ||
#endif | ||
} | ||
|
||
/// <summary> | ||
/// "Masks" every character in a string. | ||
/// </summary> | ||
/// <param name="value">String value to mask.</param> | ||
/// <param name="mask">Character to use for masking.</param> | ||
/// <returns>Masked string.</returns> | ||
public static string Mask(this string value, char? mask) | ||
{ | ||
var output = string.Empty; | ||
|
||
if (mask is null) | ||
{ | ||
return output; | ||
} | ||
|
||
foreach (var c in value) | ||
{ | ||
output += mask; | ||
} | ||
|
||
return output; | ||
} | ||
|
||
#if NETSTANDARD2_0 | ||
internal static bool Contains(this string target, string value, System.StringComparison comparisonType) | ||
{ | ||
Check failure on line 192 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 192 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 192 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (macOS)
|
||
return target.IndexOf(value, comparisonType) != -1; | ||
Check failure on line 193 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 193 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 193 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (macOS)
|
||
} | ||
Check failure on line 194 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 194 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (linux)
Check failure on line 194 in src/Spectre.Console/Extensions/StringExtensions.cs GitHub Actions / Build (macOS)
|
||
#endif | ||
|
||
/// <summary> | ||
/// "Masks" every character in a string. | ||
/// </summary> | ||
/// <param name="value">String value to mask.</param> | ||
/// <param name="mask">Character to use for masking.</param> | ||
/// <returns>Masked string.</returns> | ||
public static string Mask(this string value, char? mask) | ||
{ | ||
var output = string.Empty; | ||
|
||
if (mask is null) | ||
{ | ||
return output; | ||
} | ||
|
||
foreach (var c in value) | ||
{ | ||
output += mask; | ||
} | ||
|
||
return output; | ||
} | ||
} |