|
1 | 1 | // Copyright (c) Microsoft Corporation.
|
2 | 2 | // Licensed under the MIT License.
|
3 | 3 |
|
| 4 | +using System.Globalization; |
4 | 5 | using System.Management.Automation.Host;
|
5 | 6 | using System.Threading;
|
6 | 7 |
|
7 | 8 | using Dbg = System.Management.Automation.Diagnostics;
|
8 | 9 |
|
9 | 10 | namespace System.Management.Automation.Internal
|
10 | 11 | {
|
11 |
| - internal static |
12 |
| - class StringUtil |
| 12 | + internal static class StringUtil |
13 | 13 | {
|
14 | 14 | internal static string Format(string format, object arg0)
|
15 |
| - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0); |
| 15 | + => string.Format(CultureInfo.CurrentCulture, format, arg0); |
16 | 16 |
|
17 | 17 | internal static string Format(string format, object arg0, object arg1)
|
18 |
| - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1); |
| 18 | + => string.Format(CultureInfo.CurrentCulture, format, arg0, arg1); |
19 | 19 |
|
20 | 20 | internal static string Format(string format, object arg0, object arg1, object arg2)
|
21 |
| - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1, arg2); |
| 21 | + => string.Format(CultureInfo.CurrentCulture, format, arg0, arg1, arg2); |
22 | 22 |
|
23 | 23 | internal static string Format(string format, params object[] args)
|
24 |
| - => string.Format(Globalization.CultureInfo.CurrentCulture, format, args); |
| 24 | + => string.Format(CultureInfo.CurrentCulture, format, args); |
25 | 25 |
|
26 |
| - internal static |
27 |
| - string |
28 |
| - TruncateToBufferCellWidth(PSHostRawUserInterface rawUI, string toTruncate, int maxWidthInBufferCells) |
| 26 | + internal static string TruncateToBufferCellWidth(PSHostRawUserInterface rawUI, string toTruncate, int maxWidthInBufferCells) |
29 | 27 | {
|
30 | 28 | Dbg.Assert(rawUI != null, "need a reference");
|
31 | 29 | Dbg.Assert(maxWidthInBufferCells >= 0, "maxWidthInBufferCells must be positive");
|
@@ -58,43 +56,42 @@ internal static
|
58 | 56 | // Typical padding is at most a screen's width, any more than that and we won't bother caching.
|
59 | 57 | private const int IndentCacheMax = 120;
|
60 | 58 |
|
61 |
| - private static readonly string[] IndentCache = new string[IndentCacheMax]; |
| 59 | + private static readonly string[] s_indentCache = new string[IndentCacheMax]; |
62 | 60 |
|
63 | 61 | internal static string Padding(int countOfSpaces)
|
64 | 62 | {
|
65 | 63 | if (countOfSpaces >= IndentCacheMax)
|
66 | 64 | return new string(' ', countOfSpaces);
|
67 | 65 |
|
68 |
| - var result = IndentCache[countOfSpaces]; |
| 66 | + var result = s_indentCache[countOfSpaces]; |
69 | 67 |
|
70 | 68 | if (result == null)
|
71 | 69 | {
|
72 |
| - Interlocked.CompareExchange(ref IndentCache[countOfSpaces], new string(' ', countOfSpaces), null); |
73 |
| - result = IndentCache[countOfSpaces]; |
| 70 | + Interlocked.CompareExchange(ref s_indentCache[countOfSpaces], new string(' ', countOfSpaces), null); |
| 71 | + result = s_indentCache[countOfSpaces]; |
74 | 72 | }
|
75 | 73 |
|
76 | 74 | return result;
|
77 | 75 | }
|
78 | 76 |
|
79 | 77 | private const int DashCacheMax = 120;
|
80 | 78 |
|
81 |
| - private static readonly string[] DashCache = new string[DashCacheMax]; |
| 79 | + private static readonly string[] s_dashCache = new string[DashCacheMax]; |
82 | 80 |
|
83 | 81 | internal static string DashPadding(int count)
|
84 | 82 | {
|
85 | 83 | if (count >= DashCacheMax)
|
86 | 84 | return new string('-', count);
|
87 | 85 |
|
88 |
| - var result = DashCache[count]; |
| 86 | + var result = s_dashCache[count]; |
89 | 87 |
|
90 | 88 | if (result == null)
|
91 | 89 | {
|
92 |
| - Interlocked.CompareExchange(ref DashCache[count], new string('-', count), null); |
93 |
| - result = DashCache[count]; |
| 90 | + Interlocked.CompareExchange(ref s_dashCache[count], new string('-', count), null); |
| 91 | + result = s_dashCache[count]; |
94 | 92 | }
|
95 | 93 |
|
96 | 94 | return result;
|
97 | 95 | }
|
98 | 96 | }
|
99 | 97 | }
|
100 |
| - |
0 commit comments