File tree 1 file changed +11
-10
lines changed
1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,7 @@ internal abstract class Enums
14
14
{
15
15
internal static Enum GetEnumValue ( System . Type enumType , string s )
16
16
{
17
- #if NEW_REFLECTION
18
- if ( ! enumType . GetTypeInfo ( ) . IsEnum )
19
- #else
20
- if ( ! enumType . IsEnum )
21
- #endif
17
+ if ( ! IsEnumType ( enumType ) )
22
18
throw new ArgumentException ( "Not an enumeration type" , "enumType" ) ;
23
19
24
20
// We only want to parse single named constants
@@ -43,11 +39,7 @@ internal static Enum GetEnumValue(System.Type enumType, string s)
43
39
44
40
internal static Array GetEnumValues ( System . Type enumType )
45
41
{
46
- #if NEW_REFLECTION
47
- if ( ! enumType . GetTypeInfo ( ) . IsEnum )
48
- #else
49
- if ( ! enumType . IsEnum )
50
- #endif
42
+ if ( ! IsEnumType ( enumType ) )
51
43
throw new ArgumentException ( "Not an enumeration type" , "enumType" ) ;
52
44
53
45
#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT
@@ -73,5 +65,14 @@ internal static Enum GetArbitraryValue(System.Type enumType)
73
65
int pos = ( int ) ( DateTimeUtilities . CurrentUnixMs ( ) & int . MaxValue ) % values . Length ;
74
66
return ( Enum ) values . GetValue ( pos ) ;
75
67
}
68
+
69
+ internal static bool IsEnumType ( System . Type t )
70
+ {
71
+ #if NEW_REFLECTION
72
+ return t . GetTypeInfo ( ) . IsEnum ;
73
+ #else
74
+ return t . IsEnum ;
75
+ #endif
76
+ }
76
77
}
77
78
}
You can’t perform that action at this time.
0 commit comments