-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTypeExtensions.cs
More file actions
134 lines (118 loc) · 3.07 KB
/
TypeExtensions.cs
File metadata and controls
134 lines (118 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Reflection;
namespace XLua
{
public static class TypeExtensions
{
public static bool IsValueType(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsValueType;
#else
return type.GetTypeInfo().IsValueType;
#endif
}
public static bool IsEnum(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsEnum;
#else
return type.GetTypeInfo().IsEnum;
#endif
}
public static bool IsPrimitive(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsPrimitive;
#else
return type.GetTypeInfo().IsPrimitive;
#endif
}
public static bool IsAbstract(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsAbstract;
#else
return type.GetTypeInfo().IsAbstract;
#endif
}
public static bool IsSealed(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsSealed;
#else
return type.GetTypeInfo().IsSealed;
#endif
}
public static bool IsInterface(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsInterface;
#else
return type.GetTypeInfo().IsInterface;
#endif
}
public static bool IsClass(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsClass;
#else
return type.GetTypeInfo().IsClass;
#endif
}
public static Type BaseType(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.BaseType;
#else
return type.GetTypeInfo().BaseType;
#endif
}
public static bool IsGenericType(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsGenericType;
#else
return type.GetTypeInfo().IsGenericType;
#endif
}
public static bool IsGenericTypeDefinition(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsGenericTypeDefinition;
#else
return type.GetTypeInfo().IsGenericTypeDefinition;
#endif
}
#if UNITY_WSA && !UNITY_EDITOR
public static bool IsSubclassOf(this Type type, Type c)
{
return type.GetTypeInfo().IsSubclassOf(c);
}
public static bool IsDefined(this Type type, Type attributeType, bool inherit)
{
return type.GetTypeInfo().IsDefined(attributeType, inherit);
}
public static Type[] GetGenericParameterConstraints(this Type type)
{
return type.GetTypeInfo().GetGenericParameterConstraints();
}
#endif
public static bool IsNestedPublic(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsNestedPublic;
#else
return type.GetTypeInfo().IsNestedPublic;
#endif
}
public static bool IsPublic(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsPublic;
#else
return type.GetTypeInfo().IsPublic;
#endif
}
}
}