Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CaseInsensitiveString.cs
1using System;
4
5namespace Waher.Persistence
6{
10 public class CaseInsensitiveString : IComparable<CaseInsensitiveString>, IComparable
11 {
12 private readonly string value;
13 private readonly string lowerCase;
14 private string upperCase;
15
21 {
22 this.value = Value;
23 this.lowerCase = Value?.ToLower();
24 }
25
29 public string Value => this?.value;
30
34 public string LowerCase => this?.lowerCase;
35
39 public string UpperCase
40 {
41 get
42 {
43 if (this.upperCase is null)
44 this.upperCase = this.value?.ToUpper();
45
46 return this.upperCase;
47 }
48 }
49
51 public override string ToString()
52 {
53 return this.value ?? string.Empty;
54 }
55
60 public override int GetHashCode()
61 {
62 return this.lowerCase?.GetHashCode() ?? 0;
63 }
64
74 public override bool Equals(object obj)
75 {
76 if (obj is CaseInsensitiveString S)
77 return this.lowerCase?.Equals(S?.lowerCase) ?? (S.lowerCase is null);
78 else if (obj is string S2)
79 return this.lowerCase?.Equals(S2?.ToLower()) ?? (S2 is null);
80 else if (obj is null)
81 return this.lowerCase is null;
82 else
83 return false;
84 }
85
100 {
101 return this.lowerCase?.CompareTo(other.lowerCase) ?? (other.lowerCase is null ? 0 : -1);
102 }
103
117 public int CompareTo(object obj)
118 {
119 if (obj is CaseInsensitiveString S)
120 return this.lowerCase?.CompareTo(S.lowerCase) ?? (S.lowerCase is null ? 0 : -1);
121 else if (obj is string S2)
122 return this.lowerCase?.CompareTo(S2?.ToLower()) ?? (S2 is null ? 0 : -1);
123 else if (obj is null)
124 return this.lowerCase is null ? 0 : 1;
125 else
126 return -1;
127 }
128
134 public static implicit operator string(CaseInsensitiveString S)
135 {
136 return S?.value;
137 }
138
144 public static implicit operator CaseInsensitiveString(string S)
145 {
146 return S is null ? null : new CaseInsensitiveString(S);
147 }
148
153 {
154 return S1?.lowerCase == S2?.lowerCase;
155 }
156
161 {
162 return S1?.lowerCase != S2?.lowerCase;
163 }
164
169 {
170 return string.Compare(S1?.lowerCase, S2?.lowerCase) < 0;
171 }
172
177 {
178 return string.Compare(S1?.lowerCase, S2?.lowerCase) > 0;
179 }
180
185 {
186 return string.Compare(S1?.lowerCase, S2?.lowerCase) <= 0;
187 }
188
193 {
194 return string.Compare(S1?.lowerCase, S2?.lowerCase) >= 0;
195 }
196
200 public static bool operator ==(CaseInsensitiveString S1, string S2)
201 {
202 return S1?.lowerCase == S2?.ToLower();
203 }
204
208 public static bool operator !=(CaseInsensitiveString S1, string S2)
209 {
210 return S1?.lowerCase != S2?.ToLower();
211 }
212
216 public static bool operator <(CaseInsensitiveString S1, string S2)
217 {
218 return string.Compare(S1?.lowerCase, S2?.ToLower()) < 0;
219 }
220
224 public static bool operator >(CaseInsensitiveString S1, string S2)
225 {
226 return string.Compare(S1?.lowerCase, S2?.ToLower()) > 0;
227 }
228
232 public static bool operator <=(CaseInsensitiveString S1, string S2)
233 {
234 return string.Compare(S1?.lowerCase, S2?.ToLower()) <= 0;
235 }
236
240 public static bool operator >=(CaseInsensitiveString S1, string S2)
241 {
242 return string.Compare(S1?.lowerCase, S2?.ToLower()) >= 0;
243 }
244
248 public static bool operator ==(string S1, CaseInsensitiveString S2)
249 {
250 return string.Compare(S1, S2?.lowerCase, true) == 0;
251 }
252
256 public static bool operator !=(string S1, CaseInsensitiveString S2)
257 {
258 return string.Compare(S1, S2?.lowerCase, true) != 0;
259 }
260
264 public static bool operator <(string S1, CaseInsensitiveString S2)
265 {
266 return string.Compare(S1, S2?.lowerCase, true) < 0;
267 }
268
272 public static bool operator >(string S1, CaseInsensitiveString S2)
273 {
274 return string.Compare(S1, S2?.lowerCase, true) > 0;
275 }
276
280 public static bool operator <=(string S1, CaseInsensitiveString S2)
281 {
282 return string.Compare(S1, S2?.lowerCase, true) <= 0;
283 }
284
288 public static bool operator >=(string S1, CaseInsensitiveString S2)
289 {
290 return string.Compare(S1, S2?.lowerCase, true) >= 0;
291 }
292
297 {
298 return (CaseInsensitiveString)(S1?.value + S2?.value);
299 }
300
304 public static string operator +(CaseInsensitiveString S1, string S2)
305 {
306 return S1?.value + S2;
307 }
308
312 public static string operator +(string S1, CaseInsensitiveString S2)
313 {
314 return S1 + S2?.value;
315 }
316
320 public static readonly CaseInsensitiveString Empty = new CaseInsensitiveString(string.Empty);
321
327 public CaseInsensitiveString(char[] value)
328 : this(new string(value))
329 {
330 }
331
341 public CaseInsensitiveString(char c, int count)
342 : this(new string(c, count))
343 {
344 }
345
361 public CaseInsensitiveString(char[] value, int startIndex, int length)
362 : this(new string(value, startIndex, length))
363 {
364 }
365
377 public char this[int index] => this.value[index];
378
385 public int Length => this.value.Length;
386
387 //
401 {
402 return string.Compare(strA.lowerCase, strB.lowerCase);
403 }
404
431 public static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length, StringComparison comparisonType)
432 {
433 return string.Compare(strA.lowerCase, indexA, strB.lowerCase, indexB, length, comparisonType);
434 }
435
467 public static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
468 {
469 return string.Compare(strA.lowerCase, indexA, strB.lowerCase, indexB, length);
470 }
471
472 //
498 public static int Compare(CaseInsensitiveString strA, CaseInsensitiveString strB, StringComparison comparisonType)
499 {
500 return string.Compare(strA.lowerCase, strB.lowerCase, comparisonType);
501 }
502
503 //
534 public static int CompareOrdinal(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
535 {
536 return string.CompareOrdinal(strA.lowerCase, indexA, strB.lowerCase, indexB, length);
537 }
538
539 //
556 {
557 return string.CompareOrdinal(strA.lowerCase, strB.lowerCase);
558 }
559
560 //
577 public static CaseInsensitiveString Concat<T>(IEnumerable<T> values)
578 {
579 return (CaseInsensitiveString)string.Concat<T>(values);
580 }
581
598 {
599 return (CaseInsensitiveString)string.Concat<CaseInsensitiveString>(values);
600 }
601
615 {
616 return (CaseInsensitiveString)string.Concat(str0?.value, str1?.value);
617 }
618
638 {
639 return (CaseInsensitiveString)string.Concat(str0?.value, str1?.value, str2?.value, str3?.value);
640 }
641
657 public static CaseInsensitiveString Concat(object arg0, object arg1, object arg2)
658 {
659 return (CaseInsensitiveString)string.Concat(arg0, arg1, arg2);
660 }
661
674 public static CaseInsensitiveString Concat(object arg0, object arg1)
675 {
676 return (CaseInsensitiveString)string.Concat(arg0, arg1);
677 }
678
689 public static CaseInsensitiveString Concat(object arg0)
690 {
691 return (CaseInsensitiveString)string.Concat(arg0);
692 }
693
708 public static CaseInsensitiveString Concat(IEnumerable<CaseInsensitiveString> values)
709 {
710 return Concat<CaseInsensitiveString>(values);
711 }
712
729 public static CaseInsensitiveString Concat(params object[] args)
730 {
731 return (CaseInsensitiveString)string.Concat(args);
732 }
733
750 {
751 return (CaseInsensitiveString)string.Concat(str0?.value, str1?.value, str2?.value);
752 }
753
774 public static bool Equals(CaseInsensitiveString a, CaseInsensitiveString b, StringComparison comparisonType)
775 {
776 return string.Equals(a?.lowerCase, b?.lowerCase, comparisonType);
777 }
778
793 {
794 return string.Equals(a?.lowerCase, b?.lowerCase);
795 }
796
817 public static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0)
818 {
819 return (CaseInsensitiveString)string.Format(format.lowerCase, arg0);
820 }
821
847 public static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, params object[] args)
848 {
849 return (CaseInsensitiveString)string.Format(provider, format.lowerCase, args);
850 }
851
883 public static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1, object arg2)
884 {
885 return (CaseInsensitiveString)string.Format(provider, format.lowerCase, arg0, arg1, arg2);
886 }
887
911 public static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1)
912 {
913 return (CaseInsensitiveString)string.Format(format.lowerCase, arg0, arg1);
914 }
915
943 public static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1)
944 {
945 return (CaseInsensitiveString)string.Format(provider, format.lowerCase, arg0, arg1);
946 }
947
973 public static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0)
974 {
975 return (CaseInsensitiveString)string.Format(provider, format.lowerCase, arg0);
976 }
977
999 public static CaseInsensitiveString Format(CaseInsensitiveString format, params object[] args)
1000 {
1001 return (CaseInsensitiveString)string.Format(format.lowerCase, args);
1002 }
1003
1031 public static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1, object arg2)
1032 {
1033 return (CaseInsensitiveString)string.Format(format.lowerCase, arg0, arg1, arg2);
1034 }
1035
1045 public static bool IsNullOrEmpty(CaseInsensitiveString value)
1046 {
1047 return string.IsNullOrEmpty(value?.value);
1048 }
1049
1062 {
1063 return string.IsNullOrWhiteSpace(value?.value);
1064 }
1065
1084 public static CaseInsensitiveString Join(CaseInsensitiveString separator, params object[] values)
1085 {
1086 return (CaseInsensitiveString)string.Join(separator?.value, values);
1087 }
1088
1108 {
1109 return (CaseInsensitiveString)string.Join(separator?.value, value.ToStringArray());
1110 }
1111
1133 public static CaseInsensitiveString Join<T>(CaseInsensitiveString separator, IEnumerable<T> values)
1134 {
1135 return (CaseInsensitiveString)string.Join(separator?.value, values);
1136 }
1137
1170 public static CaseInsensitiveString Join(CaseInsensitiveString separator, CaseInsensitiveString[] value, int startIndex, int count)
1171 {
1172 return (CaseInsensitiveString)string.Join(separator?.value, value.ToStringArray(), startIndex, count);
1173 }
1174
1194 public static CaseInsensitiveString Join(CaseInsensitiveString separator, IEnumerable<CaseInsensitiveString> values)
1195 {
1196 return (CaseInsensitiveString)string.Join(separator?.value, values);
1197 }
1198
1213 {
1214 return this.lowerCase.Contains(value.lowerCase);
1215 }
1216
1244 public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
1245 {
1246 this.value.CopyTo(sourceIndex, destination, destinationIndex, count);
1247 }
1248
1268 public bool EndsWith(CaseInsensitiveString value, StringComparison comparisonType)
1269 {
1270 return this.lowerCase.EndsWith(value.lowerCase, comparisonType);
1271 }
1272
1286 {
1287 return this.lowerCase.EndsWith(value.lowerCase);
1288 }
1289
1302 {
1303 return this.lowerCase?.Equals(value?.lowerCase) ?? value is null;
1304 }
1305
1324 public bool Equals(CaseInsensitiveString value, StringComparison comparisonType)
1325 {
1326 return this.lowerCase?.Equals(value?.lowerCase, comparisonType) ?? value is null;
1327 }
1328
1350 public int IndexOf(CaseInsensitiveString value, StringComparison comparisonType)
1351 {
1352 return this.lowerCase.IndexOf(value.lowerCase, comparisonType);
1353 }
1354
1387 public int IndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
1388 {
1389 return this.lowerCase.IndexOf(value.lowerCase, startIndex, count, comparisonType);
1390 }
1391
1417 public int IndexOf(CaseInsensitiveString value, int startIndex, int count)
1418 {
1419 return this.lowerCase.IndexOf(value.lowerCase, startIndex, count);
1420 }
1421
1442 public int IndexOf(CaseInsensitiveString value, int startIndex)
1443 {
1444 return this.lowerCase.IndexOf(value.lowerCase, startIndex);
1445 }
1446
1462 {
1463 return this.lowerCase.IndexOf(value.lowerCase);
1464 }
1465
1488 public int IndexOf(char value, int startIndex, int count)
1489 {
1490 return this.lowerCase.IndexOf(char.ToLower(value), startIndex, count);
1491 }
1492
1510 public int IndexOf(char value, int startIndex)
1511 {
1512 return this.lowerCase.IndexOf(char.ToLower(value), startIndex);
1513 }
1514
1542 public int IndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
1543 {
1544 return this.lowerCase.IndexOf(value.lowerCase, startIndex, comparisonType);
1545 }
1546
1558 public int IndexOf(char value)
1559 {
1560 return this.lowerCase.IndexOf(char.ToLower(value));
1561 }
1562
1588 public int IndexOfAny(char[] anyOf, int startIndex, int count)
1589 {
1590 return this.lowerCase.IndexOfAny(ToLower(anyOf), startIndex, count);
1591 }
1592
1593 private static char[] ToLower(char[] A)
1594 {
1595 int i, c = A.Length;
1596
1597 A = (char[])A.Clone();
1598
1599 for (i = 0; i < c; i++)
1600 A[i] = char.ToLower(A[i]);
1601
1602 return A;
1603 }
1604
1627 public int IndexOfAny(char[] anyOf, int startIndex)
1628 {
1629 return this.lowerCase.IndexOfAny(ToLower(anyOf), startIndex);
1630 }
1631
1646 public int IndexOfAny(char[] anyOf)
1647 {
1648 return this.lowerCase.IndexOfAny(ToLower(anyOf));
1649 }
1650
1658 public int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex, int count)
1659 {
1660 int Result = int.MaxValue;
1661 int i, j, c = anyOf.Length;
1662 bool Found = false;
1663
1664 for (i = 0; i < c; i++)
1665 {
1666 j = this.lowerCase.IndexOf(anyOf[i].lowerCase, startIndex, count);
1667 if (j >= 0 && j < Result)
1668 {
1669 Result = j;
1670 Found = true;
1671 count = j - startIndex;
1672 if (count == 0)
1673 break;
1674 }
1675 }
1676
1677 if (Found)
1678 return Result;
1679 else
1680 return -1;
1681 }
1682
1689 public int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex)
1690 {
1691 return this.IndexOfAny(anyOf, startIndex, this.value.Length - startIndex);
1692 }
1693
1700 {
1701 return this.IndexOfAny(anyOf, 0, this.value.Length);
1702 }
1703
1725 {
1726 return (CaseInsensitiveString)this.value.Insert(startIndex, value?.value);
1727 }
1728
1740 public int LastIndexOf(char value)
1741 {
1742 return this.lowerCase.LastIndexOf(char.ToLower(value));
1743 }
1744
1765 public int LastIndexOf(char value, int startIndex)
1766 {
1767 return this.lowerCase.LastIndexOf(char.ToLower(value), startIndex);
1768 }
1769
1796 public int LastIndexOf(char value, int startIndex, int count)
1797 {
1798 return this.lowerCase.LastIndexOf(char.ToLower(value), startIndex, count);
1799 }
1800
1817 {
1818 return this.lowerCase.LastIndexOf(value.lowerCase);
1819 }
1820
1848 public int LastIndexOf(CaseInsensitiveString value, int startIndex)
1849 {
1850 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex);
1851 }
1852
1887 public int LastIndexOf(CaseInsensitiveString value, int startIndex, int count)
1888 {
1889 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, count);
1890 }
1891
1933 public int LastIndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
1934 {
1935 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, count, comparisonType);
1936 }
1937
1973 public int LastIndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
1974 {
1975 return this.lowerCase.LastIndexOf(value.lowerCase, startIndex, comparisonType);
1976 }
1977
2000 public int LastIndexOf(CaseInsensitiveString value, StringComparison comparisonType)
2001 {
2002 return this.lowerCase.LastIndexOf(value.lowerCase, comparisonType);
2003 }
2004
2019 public int LastIndexOfAny(char[] anyOf)
2020 {
2021 return this.lowerCase.LastIndexOfAny(ToLower(anyOf));
2022 }
2023
2049 public int LastIndexOfAny(char[] anyOf, int startIndex)
2050 {
2051 return this.lowerCase.LastIndexOfAny(ToLower(anyOf), startIndex);
2052 }
2053
2083 public int LastIndexOfAny(char[] anyOf, int startIndex, int count)
2084 {
2085 return this.lowerCase.LastIndexOfAny(ToLower(anyOf), startIndex, count);
2086 }
2087
2106 public CaseInsensitiveString PadLeft(int totalWidth)
2107 {
2108 return (CaseInsensitiveString)this.value.PadLeft(totalWidth);
2109 }
2110
2133 public CaseInsensitiveString PadLeft(int totalWidth, char paddingChar)
2134 {
2135 return (CaseInsensitiveString)this.value.PadLeft(totalWidth, paddingChar);
2136 }
2137
2156 public CaseInsensitiveString PadRight(int totalWidth)
2157 {
2158 return (CaseInsensitiveString)this.value.PadRight(totalWidth);
2159 }
2160
2183 public CaseInsensitiveString PadRight(int totalWidth, char paddingChar)
2184 {
2185 return (CaseInsensitiveString)this.value.PadRight(totalWidth, paddingChar);
2186 }
2187
2202 public CaseInsensitiveString Remove(int startIndex)
2203 {
2204 return (CaseInsensitiveString)this.value.Remove(startIndex);
2205 }
2206
2224 public CaseInsensitiveString Remove(int startIndex, int count)
2225 {
2226 return (CaseInsensitiveString)this.value.Remove(startIndex, count);
2227 }
2228
2251 {
2252 string s = this.value;
2253 string s2 = this.lowerCase;
2254 int i = s2.IndexOf(oldValue.lowerCase);
2255 int c = oldValue.Length;
2256 int d = newValue.Length;
2257 int Diff = 0;
2258
2259 while (i >= 0)
2260 {
2261 s = s.Remove(i + Diff, c);
2262 s = s.Insert(i + Diff, newValue?.value);
2263
2264 i = s2.IndexOf(oldValue.lowerCase, i + c);
2265 Diff += d - c;
2266 }
2267
2268 return (CaseInsensitiveString)s;
2269 }
2270
2286 public CaseInsensitiveString Replace(char oldChar, char newChar)
2287 {
2288 string s = this.value.Replace(oldChar, newChar);
2289 char ch = char.ToLower(oldChar);
2290
2291 if (ch != oldChar)
2292 s = s.Replace(ch, char.ToLower(newChar));
2293 else
2294 s = s.Replace(char.ToUpper(oldChar), char.ToUpper(newChar));
2295
2296 return (CaseInsensitiveString)s;
2297 }
2298
2312 public CaseInsensitiveString[] Split(params char[] separator)
2313 {
2314 return this.Split(separator, int.MaxValue, StringSplitOptions.None);
2315 }
2316
2337 public CaseInsensitiveString[] Split(char[] separator, int count)
2338 {
2339 return this.Split(separator, count, StringSplitOptions.None);
2340 }
2341
2370 public CaseInsensitiveString[] Split(char[] separator, int count, StringSplitOptions options)
2371 {
2372 char[] A = ToLower(separator);
2373 int i = this.lowerCase.IndexOfAny(A);
2374 int Last = -1;
2376 string s;
2377
2378 while (i >= 0 && count > 0)
2379 {
2380 s = this.value.Substring(Last + 1, i - Last - 1);
2381
2382 if (options != StringSplitOptions.RemoveEmptyEntries || !string.IsNullOrEmpty(s))
2383 {
2384 count--;
2385 Result.Add((CaseInsensitiveString)s);
2386 }
2387
2388 Last = i;
2389 i = this.lowerCase.IndexOfAny(A, i + 1);
2390 }
2391
2392 if (count > 0)
2393 {
2394 s = this.value.Substring(Last + 1);
2395
2396 if (options != StringSplitOptions.RemoveEmptyEntries || !string.IsNullOrEmpty(s))
2397 Result.Add((CaseInsensitiveString)this.value.Substring(Last + 1));
2398 }
2399
2400 return Result.ToArray();
2401 }
2402
2425 public CaseInsensitiveString[] Split(char[] separator, StringSplitOptions options)
2426 {
2427 return this.Split(separator, int.MaxValue, options);
2428 }
2429
2457 public CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, int count, StringSplitOptions options)
2458 {
2459 int i = this.IndexOfAny(separator);
2460 int Last = -1;
2462 string s;
2463
2464 while (i >= 0 && count > 0)
2465 {
2466 s = this.value.Substring(Last + 1, i - Last - 1);
2467
2468 if (options != StringSplitOptions.RemoveEmptyEntries || !string.IsNullOrEmpty(s))
2469 {
2470 count--;
2471 Result.Add((CaseInsensitiveString)s);
2472 }
2473
2474 Last = i;
2475 i = this.IndexOfAny(separator, i + 1);
2476 }
2477
2478 if (count > 0)
2479 {
2480 s = this.value.Substring(Last + 1);
2481
2482 if (options != StringSplitOptions.RemoveEmptyEntries || !string.IsNullOrEmpty(s))
2483 Result.Add((CaseInsensitiveString)this.value.Substring(Last + 1));
2484 }
2485
2486 return Result.ToArray();
2487
2488 }
2489
2511 public CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, StringSplitOptions options)
2512 {
2513 return this.Split(separator, int.MaxValue, options);
2514 }
2515
2530 {
2531 return this.lowerCase.StartsWith(value.lowerCase);
2532 }
2533
2553 public bool StartsWith(CaseInsensitiveString value, StringComparison comparisonType)
2554 {
2555 return this.lowerCase.StartsWith(value.lowerCase, comparisonType);
2556 }
2557
2577 public CaseInsensitiveString Substring(int startIndex, int length)
2578 {
2579 return (CaseInsensitiveString)this.value.Substring(startIndex, length);
2580 }
2581
2597 public CaseInsensitiveString Substring(int startIndex)
2598 {
2599 return (CaseInsensitiveString)this.value.Substring(startIndex);
2600 }
2601
2620 public char[] ToCharArray(int startIndex, int length)
2621 {
2622 return this.value.ToCharArray(startIndex, length);
2623 }
2624
2633 public char[] ToCharArray()
2634 {
2635 return this.value.ToCharArray();
2636 }
2637
2648 {
2649 return (CaseInsensitiveString)this.value.Trim();
2650 }
2651
2666 public CaseInsensitiveString Trim(params char[] trimChars)
2667 {
2668 return (CaseInsensitiveString)this.value.Trim(UpperAndLowerCases(trimChars));
2669 }
2670
2671 private static char[] UpperAndLowerCases(char[] trimChars)
2672 {
2674 int i, c = trimChars.Length;
2675 char ch, ch2;
2676
2677 for (i = 0; i < c; i++)
2678 {
2679 ch = trimChars[i];
2680 A.Add(ch);
2681
2682 ch2 = char.ToLower(ch);
2683 if (ch2 != ch)
2684 A.Add(ch2);
2685
2686 ch2 = char.ToUpper(ch);
2687 if (ch2 != ch)
2688 A.Add(ch2);
2689 }
2690
2691 return A.ToArray();
2692 }
2693
2708 public CaseInsensitiveString TrimEnd(params char[] trimChars)
2709 {
2710 return (CaseInsensitiveString)this.value.TrimEnd(UpperAndLowerCases(trimChars));
2711 }
2712
2725 public CaseInsensitiveString TrimStart(params char[] trimChars)
2726 {
2727 return (CaseInsensitiveString)this.value.TrimStart(UpperAndLowerCases(trimChars));
2728 }
2729
2730 }
2731}
Represents a case-insensitive string.
bool StartsWith(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether the beginning of this string instance matches the specified string when compared u...
int IndexOf(char value, int startIndex)
Reports the zero-based index of the first occurrence of the specified Unicode character in this strin...
int LastIndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
Reports the zero-based index of the last occurrence of a specified string within the current System....
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool operator==(CaseInsensitiveString S1, CaseInsensitiveString S2)
Equality operator
static bool operator<(CaseInsensitiveString S1, CaseInsensitiveString S2)
Lesser-than operator
static CaseInsensitiveString Concat< T >(IEnumerable< T > values)
Concatenates the members of an System.Collections.Generic.IEnumerable`1 implementation.
bool Equals(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether this string and a specified System.CaseInsensitiveString object have the same valu...
CaseInsensitiveString Trim(params char[] trimChars)
Removes all leading and trailing occurrences of a set of characters specified in an array from the cu...
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
int LastIndexOf(CaseInsensitiveString value)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
bool Contains(CaseInsensitiveString value)
Returns a value indicating whether a specified substring occurs within this string.
CaseInsensitiveString TrimStart(params char[] trimChars)
Removes all leading occurrences of a set of characters specified in an array from the current System....
int IndexOfAny(CaseInsensitiveString[] anyOf)
Checks for the first occurrence of the case-insensitive strings in anyOf .
static CaseInsensitiveString Join(CaseInsensitiveString separator, CaseInsensitiveString[] value, int startIndex, int count)
Concatenates the specified elements of a string array, using the specified separator between each ele...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0)
Replaces the format item or items in a specified string with the string representation of the corresp...
int LastIndexOfAny(char[] anyOf, int startIndex)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
CaseInsensitiveString PadRight(int totalWidth)
Returns a new string that left-aligns the characters in this string by padding them with spaces on th...
int Length
Gets the number of characters in the current CaseInsensitiveString object.
CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, int count, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0)
Replaces one or more format items in a specified string with the string representation of a specified...
static CaseInsensitiveString Concat(object arg0)
Creates the string representation of a specified object.
string LowerCase
Lower-case representation of the case-insensitive string.
CaseInsensitiveString PadLeft(int totalWidth, char paddingChar)
Returns a new string that right-aligns the characters in this instance by padding them on the left wi...
bool Equals(CaseInsensitiveString value)
Determines whether this instance and another specified System.CaseInsensitiveString object have the s...
CaseInsensitiveString(string Value)
Represents a case-insensitive string.
int IndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
CaseInsensitiveString PadRight(int totalWidth, char paddingChar)
Returns a new string that left-aligns the characters in this string by padding them on the right with...
int IndexOf(char value, int startIndex, int count)
Reports the zero-based index of the first occurrence of the specified character in this instance....
CaseInsensitiveString PadLeft(int totalWidth)
Returns a new string that right-aligns the characters in this instance by padding them with spaces on...
int LastIndexOf(char value)
Reports the zero-based index position of the last occurrence of a specified Unicode character within ...
static bool operator>=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Greater-than-or-equal-to operator
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
static CaseInsensitiveString Format(CaseInsensitiveString format, params object[] args)
Replaces the format item in a specified string with the string representation of a corresponding obje...
int IndexOfAny(char[] anyOf)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
static bool Equals(CaseInsensitiveString a, CaseInsensitiveString b, StringComparison comparisonType)
Determines whether two specified System.CaseInsensitiveString objects have the same value....
static CaseInsensitiveString operator+(CaseInsensitiveString S1, CaseInsensitiveString S2)
Addition operator
static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length, StringComparison comparisonType)
Compares substrings of two specified CaseInsensitiveString objects using the specified rules,...
int LastIndexOf(char value, int startIndex)
Reports the zero-based index position of the last occurrence of a specified Unicode character within ...
CaseInsensitiveString Replace(char oldChar, char newChar)
Returns a new string in which all occurrences of a specified Unicode character in this instance are r...
int IndexOf(CaseInsensitiveString value)
Reports the zero-based index of the first occurrence of the specified string in this instance.
CaseInsensitiveString TrimEnd(params char[] trimChars)
Removes all trailing occurrences of a set of characters specified in an array from the current System...
CaseInsensitiveString[] Split(char[] separator, int count)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, params object[] args)
Replaces the format items in a specified string with the string representations of corresponding obje...
int LastIndexOfAny(char[] anyOf, int startIndex, int count)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1, CaseInsensitiveString str2)
Concatenates three specified instances of CaseInsensitiveString.
static CaseInsensitiveString Join(CaseInsensitiveString separator, IEnumerable< CaseInsensitiveString > values)
Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1 collection of type...
int IndexOf(char value)
Reports the zero-based index of the first occurrence of the specified Unicode character in this strin...
CaseInsensitiveString[] Split(char[] separator, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
CaseInsensitiveString Trim()
Removes all leading and trailing white-space characters from the current CaseInsensitiveString object...
static int Compare(CaseInsensitiveString strA, CaseInsensitiveString strB, StringComparison comparisonType)
Compares two specified CaseInsensitiveString objects using the specified rules, and returns an intege...
int CompareTo(CaseInsensitiveString other)
Compares this instance with a specified System.CaseInsensitiveString object and indicates whether thi...
CaseInsensitiveString(char[] value)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by an array of U...
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
Copies a specified number of characters from a specified position in this instance to a specified pos...
CaseInsensitiveString Replace(CaseInsensitiveString oldValue, CaseInsensitiveString newValue)
Returns a new string in which all occurrences of a specified string in the current instance are repla...
CaseInsensitiveString Remove(int startIndex)
Returns a new string in which all the characters in the current instance, beginning at a specified po...
static int CompareOrdinal(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
Compares substrings of two specified CaseInsensitiveString objects by evaluating the numeric values o...
static CaseInsensitiveString Join(CaseInsensitiveString separator, params CaseInsensitiveString[] value)
Concatenates all the elements of a string array, using the specified separator between each element.
string UpperCase
Upper-case representation of the case-insensitive string.
int LastIndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
static bool operator<=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Lesser-than-or-equal-to operator
CaseInsensitiveString(char[] value, int startIndex, int length)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by an array of U...
CaseInsensitiveString[] Split(CaseInsensitiveString[] separator, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
int LastIndexOfAny(char[] anyOf)
Reports the zero-based index position of the last occurrence in this instance of one or more characte...
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1, object arg2)
Replaces the format items in a specified string with the string representation of three specified obj...
bool StartsWith(CaseInsensitiveString value)
Determines whether the beginning of this string instance matches the specified string.
static bool IsNullOrWhiteSpace(CaseInsensitiveString value)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
static CaseInsensitiveString Join(CaseInsensitiveString separator, params object[] values)
Concatenates the elements of an object array, using the specified separator between each element.
CaseInsensitiveString[] Split(params char[] separator)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
static CaseInsensitiveString Concat(object arg0, object arg1)
Concatenates the string representations of two specified objects.
CaseInsensitiveString Insert(int startIndex, CaseInsensitiveString value)
Returns a new string in which a specified string is inserted at a specified index position in this in...
override int GetHashCode()
Returns the hash code for this string.
static int Compare(CaseInsensitiveString strA, CaseInsensitiveString strB)
Compares two specified CaseInsensitiveString objects and returns an integer that indicates their rela...
static bool operator>(CaseInsensitiveString S1, CaseInsensitiveString S2)
Greater-than operator
char[] ToCharArray()
Copies the characters in this instance to a Unicode character array.
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1)
Replaces the format items in a specified string with the string representation of two specified objec...
int IndexOf(CaseInsensitiveString value, int startIndex)
Reports the zero-based index of the first occurrence of the specified string in this instance....
int LastIndexOf(char value, int startIndex, int count)
Reports the zero-based index position of the last occurrence of the specified Unicode character in a ...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1)
Concatenates two specified instances of CaseInsensitiveString.
CaseInsensitiveString Substring(int startIndex)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
int LastIndexOf(CaseInsensitiveString value, int startIndex, int count)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
int IndexOf(CaseInsensitiveString value, int startIndex, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
int IndexOf(CaseInsensitiveString value, int startIndex, int count)
Reports the zero-based index of the first occurrence of the specified string in this instance....
static CaseInsensitiveString Concat(params object[] args)
Concatenates the string representations of the elements in a specified System.Object array.
int LastIndexOf(CaseInsensitiveString value, int startIndex)
Reports the zero-based index position of the last occurrence of a specified string within this instan...
int LastIndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the last occurrence of a specified string within the current System....
static CaseInsensitiveString Format(CaseInsensitiveString format, object arg0, object arg1, object arg2)
Replaces the format items in a specified string with the string representation of three specified obj...
CaseInsensitiveString(char c, int count)
Initializes a new instance of the CaseInsensitiveString class to the value indicated by a specified U...
static int CompareOrdinal(CaseInsensitiveString strA, CaseInsensitiveString strB)
Compares two specified CaseInsensitiveString objects by evaluating the numeric values of the correspo...
static CaseInsensitiveString Concat(object arg0, object arg1, object arg2)
Concatenates the string representations of three specified objects.
int CompareTo(object obj)
Compares this instance with a specified System.CaseInsensitiveString object and indicates whether thi...
static CaseInsensitiveString Join< T >(CaseInsensitiveString separator, IEnumerable< T > values)
Concatenates the members of a collection, using the specified separator between each member.
CaseInsensitiveString Substring(int startIndex, int length)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
int IndexOfAny(char[] anyOf, int startIndex)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
CaseInsensitiveString Remove(int startIndex, int count)
Returns a new string in which a specified number of characters in the current instance beginning at a...
int IndexOfAny(char[] anyOf, int startIndex, int count)
Reports the zero-based index of the first occurrence in this instance of any character in a specified...
static bool operator!=(CaseInsensitiveString S1, CaseInsensitiveString S2)
Non-Equality operator
override bool Equals(object obj)
Determines whether this instance and a specified object, which must also be a System....
static CaseInsensitiveString Format(IFormatProvider provider, CaseInsensitiveString format, object arg0, object arg1)
Replaces the format items in a specified string with the string representation of two specified objec...
int IndexOf(CaseInsensitiveString value, int startIndex, int count, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
static CaseInsensitiveString Concat(IEnumerable< CaseInsensitiveString > values)
Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1 collection of type...
bool EndsWith(CaseInsensitiveString value)
Determines whether the end of this string instance matches the specified string.
CaseInsensitiveString[] Split(char[] separator, int count, StringSplitOptions options)
Returns a string array that contains the substrings in this string that are delimited by elements of ...
static int Compare(CaseInsensitiveString strA, int indexA, CaseInsensitiveString strB, int indexB, int length)
Compares substrings of two specified CaseInsensitiveString objects and returns an integer that indica...
static CaseInsensitiveString Concat(CaseInsensitiveString str0, CaseInsensitiveString str1, CaseInsensitiveString str2, CaseInsensitiveString str3)
Concatenates four specified instances of CaseInsensitiveString.
char[] ToCharArray(int startIndex, int length)
Copies the characters in a specified substring in this instance to a Unicode character array.
static CaseInsensitiveString Concat(params CaseInsensitiveString[] values)
Concatenates the elements of a specified CaseInsensitiveString array.
int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex)
Checks for the first occurrence of the case-insensitive strings in anyOf .
bool EndsWith(CaseInsensitiveString value, StringComparison comparisonType)
Determines whether the end of this string instance matches the specified string when compared using t...
static bool Equals(CaseInsensitiveString a, CaseInsensitiveString b)
Determines whether two specified System.CaseInsensitiveString objects have the same value.
int IndexOfAny(CaseInsensitiveString[] anyOf, int startIndex, int count)
Checks for the first occurrence of the case-insensitive strings in anyOf .
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
T[] ToArray()
Returns an array containing all elements of the collection.