Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ComparerHelpers.cs
Go to the documentation of this file.
2
3internal static class ComparerHelpers
4{
5 internal static object CreateDefaultComparer(Type type)
6 {
7 object obj = null;
9 if (typeof(IComparable<>).MakeGenericType(type).IsAssignableFrom(type))
10 {
12 }
13 else if (type.IsGenericType)
14 {
15 if (type.GetGenericTypeDefinition() == typeof(Nullable<>))
16 {
18 }
19 }
20 else if (type.IsEnum)
21 {
23 }
25 }
26
28 {
29 RuntimeType runtimeType = (RuntimeType)nullableType.GetGenericArguments()[0];
30 if (typeof(IComparable<>).MakeGenericType(runtimeType).IsAssignableFrom(runtimeType))
31 {
33 }
34 return null;
35 }
36
38 {
40 if ((uint)(typeCode - 5) <= 7u)
41 {
43 }
44 return null;
45 }
46
47 internal static object CreateDefaultEqualityComparer(Type type)
48 {
49 object obj = null;
51 if (type == typeof(byte))
52 {
54 }
55 else if (type == typeof(string))
56 {
58 }
59 else if (type.IsAssignableTo(typeof(IEquatable<>).MakeGenericType(type)))
60 {
62 }
63 else if (type.IsGenericType)
64 {
65 if (type.GetGenericTypeDefinition() == typeof(Nullable<>))
66 {
68 }
69 }
70 else if (type.IsEnum)
71 {
73 }
75 }
76
86
88 {
90 if ((uint)(typeCode - 5) <= 7u)
91 {
93 }
94 return null;
95 }
96}
static object TryCreateEnumEqualityComparer(RuntimeType enumType)
static object TryCreateEnumComparer(RuntimeType enumType)
static object TryCreateNullableComparer(RuntimeType nullableType)
static object CreateDefaultComparer(Type type)
static object CreateDefaultEqualityComparer(Type type)
static object TryCreateNullableEqualityComparer(RuntimeType nullableType)
static Type GetUnderlyingType(Type enumType)
Definition Enum.cs:309
static TypeCode GetTypeCode(Type? type)
Definition Type.cs:919
TypeCode
Definition TypeCode.cs:4
static unsafe object CreateInstanceForAnotherGenericParameter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] RuntimeType type, RuntimeType genericParameter)