/
TypeHelpers.cs
71 lines (66 loc) · 1.49 KB
/
TypeHelpers.cs
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
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace FastMember
{
internal static class TypeHelpers
{
#if COREFX
public static readonly Type[] EmptyTypes = new Type[0];
#else
public static readonly Type[] EmptyTypes = Type.EmptyTypes;
#endif
public static bool _IsValueType(this Type type)
{
#if COREFX
return type.GetTypeInfo().IsValueType;
#else
return type.IsValueType;
#endif
}
public static bool _IsPublic(this Type type)
{
#if COREFX
return type.GetTypeInfo().IsPublic;
#else
return type.IsPublic;
#endif
}
public static bool _IsNestedPublic(this Type type)
{
#if COREFX
return type.GetTypeInfo().IsNestedPublic;
#else
return type.IsNestedPublic;
#endif
}
public static bool _IsClass(this Type type)
{
#if COREFX
return type.GetTypeInfo().IsClass;
#else
return type.IsClass;
#endif
}
public static bool _IsAbstract(this Type type)
{
#if COREFX
return type.GetTypeInfo().IsAbstract;
#else
return type.IsAbstract;
#endif
}
public static Type _CreateType(this TypeBuilder type)
{
#if COREFX
return type.CreateTypeInfo().AsType();
#else
return type.CreateType();
#endif
}
public static int Min(int x, int y)
{
return x < y ? x : y;
}
}
}