Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CultureAwareComparer.cs
Go to the documentation of this file.
5
6namespace System;
7
9[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
11{
13
15
16 private readonly CompareInfo _compareInfo;
17
18 private readonly CompareOptions _options;
19
24
26 {
28 if (((uint)options & 0xDFFFFFE0u) != 0)
29 {
30 throw new ArgumentException(SR.Argument_InvalidFlag, "options");
31 }
33 }
34
36 {
37 _compareInfo = (CompareInfo)info.GetValue("_compareInfo", typeof(CompareInfo));
38 bool boolean = info.GetBoolean("_ignoreCase");
39 object valueNoThrow = info.GetValueNoThrow("_options", typeof(CompareOptions));
40 if (valueNoThrow != null)
41 {
43 }
44 _options |= (CompareOptions)(boolean ? 1 : 0);
45 }
46
47 public override int Compare(string? x, string? y)
48 {
49 if ((object)x == y)
50 {
51 return 0;
52 }
53 if (x == null)
54 {
55 return -1;
56 }
57 if (y == null)
58 {
59 return 1;
60 }
61 return _compareInfo.Compare(x, y, _options);
62 }
63
64 public override bool Equals(string? x, string? y)
65 {
66 if ((object)x == y)
67 {
68 return true;
69 }
70 if (x == null || y == null)
71 {
72 return false;
73 }
74 return _compareInfo.Compare(x, y, _options) == 0;
75 }
76
77 public override int GetHashCode(string obj)
78 {
79 if (obj == null)
80 {
81 throw new ArgumentNullException("obj");
82 }
84 }
85
86 public override bool Equals([NotNullWhen(true)] object? obj)
87 {
89 {
90 return _compareInfo.Equals(cultureAwareComparer._compareInfo);
91 }
92 return false;
93 }
94
95 public override int GetHashCode()
96 {
97 return _compareInfo.GetHashCode() ^ (int)(_options & (CompareOptions)2147483647);
98 }
99
101 {
102 info.AddValue("_compareInfo", _compareInfo);
103 info.AddValue("_options", _options);
104 info.AddValue("_ignoreCase", (_options & CompareOptions.IgnoreCase) != 0);
105 }
106
113}
override bool Equals([NotNullWhen(true)] object? obj)
static readonly CultureAwareComparer InvariantIgnoreCaseInstance
static readonly CultureAwareComparer InvariantCaseSensitiveInstance
readonly CompareOptions _options
override int Compare(string? x, string? y)
override bool IsWellKnownCultureAwareComparerCore([NotNullWhen(true)] out CompareInfo compareInfo, out CompareOptions compareOptions)
readonly CompareInfo _compareInfo
void GetObjectData(SerializationInfo info, StreamingContext context)
CultureAwareComparer(CompareInfo compareInfo, CompareOptions options)
CultureAwareComparer(CultureInfo culture, CompareOptions options)
CultureAwareComparer(SerializationInfo info, StreamingContext context)
override int GetHashCode(string obj)
override bool Equals(string? x, string? y)
static readonly CompareInfo Invariant
int Compare(string? string1, string? string2)
override bool Equals([NotNullWhen(true)] object? value)
static string Argument_InvalidFlag
Definition SR.cs:688
Definition SR.cs:7