|
1 | 1 | using System; |
2 | 2 |
|
3 | | -namespace OrchardCoreContrib.PoExtractor |
| 3 | +namespace OrchardCoreContrib.PoExtractor; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// Extension methods for <see cref="string"/>. |
| 7 | +/// </summary> |
| 8 | +public static class StringExtensions |
4 | 9 | { |
5 | 10 | /// <summary> |
6 | | - /// Extension methods for <see cref="string"/>. |
| 11 | + /// Removes the given value from the start of the text. |
7 | 12 | /// </summary> |
8 | | - public static class StringExtensions |
| 13 | + /// <param name="text">The source text.</param> |
| 14 | + /// <param name="trimText">The value to be trimmed.</param> |
| 15 | + public static string TrimStart(this string text, string trimText) |
9 | 16 | { |
10 | | - /// <summary> |
11 | | - /// Removes the given value from the start of the text. |
12 | | - /// </summary> |
13 | | - /// <param name="text">The source text.</param> |
14 | | - /// <param name="trimText">The value to be trimmed.</param> |
15 | | - public static string TrimStart(this string text, string trimText) |
| 17 | + if (string.IsNullOrEmpty(text)) |
16 | 18 | { |
17 | | - if (string.IsNullOrEmpty(text)) |
18 | | - { |
19 | | - throw new ArgumentException($"'{nameof(text)}' cannot be null or empty.", nameof(text)); |
20 | | - } |
| 19 | + throw new ArgumentException($"'{nameof(text)}' cannot be null or empty.", nameof(text)); |
| 20 | + } |
21 | 21 |
|
22 | | - if (string.IsNullOrEmpty(trimText)) |
23 | | - { |
24 | | - throw new ArgumentException($"'{nameof(trimText)}' cannot be null or empty.", nameof(trimText)); |
25 | | - } |
| 22 | + if (string.IsNullOrEmpty(trimText)) |
| 23 | + { |
| 24 | + throw new ArgumentException($"'{nameof(trimText)}' cannot be null or empty.", nameof(trimText)); |
| 25 | + } |
26 | 26 |
|
27 | | - var index = text.IndexOf(trimText); |
| 27 | + var index = text.IndexOf(trimText); |
28 | 28 |
|
29 | | - return index < 0 |
30 | | - ? text |
31 | | - : text.Remove(index, trimText.Length); |
32 | | - } |
| 29 | + return index < 0 |
| 30 | + ? text |
| 31 | + : text.Remove(index, trimText.Length); |
33 | 32 | } |
34 | 33 | } |
0 commit comments