Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateDefaultEqualityComparer()

static object System.Collections.Generic.ComparerHelpers.CreateDefaultEqualityComparer ( Type type)
inlinestaticpackage

Definition at line 47 of file ComparerHelpers.cs.

48 {
49 object obj = null;
50 RuntimeType runtimeType = (RuntimeType)type;
51 if (type == typeof(byte))
52 {
53 obj = new ByteEqualityComparer();
54 }
55 else if (type == typeof(string))
56 {
57 obj = new GenericEqualityComparer<string>();
58 }
59 else if (type.IsAssignableTo(typeof(IEquatable<>).MakeGenericType(type)))
60 {
61 obj = RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(GenericEqualityComparer<string>), runtimeType);
62 }
63 else if (type.IsGenericType)
64 {
65 if (type.GetGenericTypeDefinition() == typeof(Nullable<>))
66 {
68 }
69 }
70 else if (type.IsEnum)
71 {
73 }
74 return obj ?? RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(ObjectEqualityComparer<object>), runtimeType);
75 }
static object TryCreateEnumEqualityComparer(RuntimeType enumType)
static object TryCreateNullableEqualityComparer(RuntimeType nullableType)

References System.RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter(), System.obj, System.Collections.Generic.ComparerHelpers.TryCreateEnumEqualityComparer(), System.Collections.Generic.ComparerHelpers.TryCreateNullableEqualityComparer(), and System.type.