Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringComparer.cs
Go to the documentation of this file.
6
7namespace System;
8
10[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
11public abstract class StringComparer : IComparer, IEqualityComparer, IComparer<string?>, IEqualityComparer<string?>
12{
14
16
18
20
22
24
26 {
27 return comparisonType switch
28 {
29 StringComparison.CurrentCulture => CurrentCulture,
30 StringComparison.CurrentCultureIgnoreCase => CurrentCultureIgnoreCase,
31 StringComparison.InvariantCulture => InvariantCulture,
32 StringComparison.InvariantCultureIgnoreCase => InvariantCultureIgnoreCase,
33 StringComparison.Ordinal => Ordinal,
34 StringComparison.OrdinalIgnoreCase => OrdinalIgnoreCase,
35 _ => throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType"),
36 };
37 }
38
40 {
41 if (culture == null)
42 {
43 throw new ArgumentNullException("culture");
44 }
46 }
47
49 {
50 if (culture == null)
51 {
52 throw new ArgumentNullException("culture");
53 }
55 }
56
58 {
60 {
61 comparer = internalStringEqualityComparer.GetUnderlyingEqualityComparer();
62 }
64 {
66 {
67 ignoreCase = false;
68 return true;
69 }
70 ignoreCase = false;
71 return false;
72 }
73 return stringComparer.IsWellKnownOrdinalComparerCore(out ignoreCase);
74 }
75
76 private protected virtual bool IsWellKnownOrdinalComparerCore(out bool ignoreCase)
77 {
78 ignoreCase = false;
79 return false;
80 }
81
96
98 {
99 compareInfo = null;
101 return false;
102 }
103
104 public int Compare(object? x, object? y)
105 {
106 if (x == y)
107 {
108 return 0;
109 }
110 if (x == null)
111 {
112 return -1;
113 }
114 if (y == null)
115 {
116 return 1;
117 }
118 if (x is string x2 && y is string y2)
119 {
120 return Compare(x2, y2);
121 }
123 {
124 return comparable.CompareTo(y);
125 }
127 }
128
129 public new bool Equals(object? x, object? y)
130 {
131 if (x == y)
132 {
133 return true;
134 }
135 if (x == null || y == null)
136 {
137 return false;
138 }
139 if (x is string x2 && y is string y2)
140 {
141 return Equals(x2, y2);
142 }
143 return x.Equals(y);
144 }
145
146 public int GetHashCode(object obj)
147 {
148 if (obj == null)
149 {
150 throw new ArgumentNullException("obj");
151 }
152 if (obj is string obj2)
153 {
154 return GetHashCode(obj2);
155 }
156 return obj.GetHashCode();
157 }
158
159 public abstract int Compare(string? x, string? y);
160
161 public abstract bool Equals(string? x, string? y);
162
163 public abstract int GetHashCode(string obj);
164}
static readonly CultureAwareComparer InvariantIgnoreCaseInstance
static readonly CultureAwareComparer InvariantCaseSensitiveInstance
static CultureInfo CurrentCulture
static readonly OrdinalCaseSensitiveComparer Instance
static readonly OrdinalIgnoreCaseComparer Instance
static string Argument_ImplementIComparable
Definition SR.cs:34
static string NotSupported_StringComparison
Definition SR.cs:1712
Definition SR.cs:7
static StringComparer Ordinal
static StringComparer InvariantCulture
int Compare(string? x, string? y)
virtual bool IsWellKnownCultureAwareComparerCore([NotNullWhen(true)] out CompareInfo compareInfo, out CompareOptions compareOptions)
static bool IsWellKnownCultureAwareComparer(IEqualityComparer< string?>? comparer, [NotNullWhen(true)] out CompareInfo? compareInfo, out CompareOptions compareOptions)
static StringComparer FromComparison(StringComparison comparisonType)
new bool Equals(object? x, object? y)
int GetHashCode(object obj)
int Compare(object? x, object? y)
static StringComparer Create(CultureInfo culture, bool ignoreCase)
static StringComparer OrdinalIgnoreCase
static StringComparer CurrentCultureIgnoreCase
static StringComparer CurrentCulture
static bool IsWellKnownOrdinalComparer(IEqualityComparer< string?>? comparer, out bool ignoreCase)
static StringComparer Create(CultureInfo culture, CompareOptions options)
bool Equals(string? x, string? y)
int GetHashCode(string obj)
static StringComparer InvariantCultureIgnoreCase
virtual bool IsWellKnownOrdinalComparerCore(out bool ignoreCase)