summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-11-21 23:43:35 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-11-21 23:43:35 +0700
commit304725950a7a51a3e4d67e214c0e0d8238301d60 (patch)
tree8c3f73288f999db888d70f522e10f33486935a06 /crypto/src/util
parentMerge branch 'master' of git.bouncycastle.org:bc-csharp into pcl (diff)
parentAdd Platform method for getting the type name of an object (diff)
downloadBouncyCastle.NET-ed25519-304725950a7a51a3e4d67e214c0e0d8238301d60.tar.xz
Merge branch 'master' of git.bouncycastle.org:bc-csharp into pcl
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/Enums.cs21
-rw-r--r--crypto/src/util/Platform.cs5
2 files changed, 16 insertions, 10 deletions
diff --git a/crypto/src/util/Enums.cs b/crypto/src/util/Enums.cs
index 660bbe73f..9e908c4c0 100644
--- a/crypto/src/util/Enums.cs
+++ b/crypto/src/util/Enums.cs
@@ -14,11 +14,7 @@ namespace Org.BouncyCastle.Utilities
     {
         internal static Enum GetEnumValue(System.Type enumType, string s)
         {
-#if NEW_REFLECTION
-            if (!enumType.GetTypeInfo().IsEnum)
-#else
-            if (!enumType.IsEnum)
-#endif
+            if (!IsEnumType(enumType))
                 throw new ArgumentException("Not an enumeration type", "enumType");
 
             // We only want to parse single named constants
@@ -43,11 +39,7 @@ namespace Org.BouncyCastle.Utilities
 
         internal static Array GetEnumValues(System.Type enumType)
         {
-#if NEW_REFLECTION
-            if (!enumType.GetTypeInfo().IsEnum)
-#else
-            if (!enumType.IsEnum)
-#endif
+            if (!IsEnumType(enumType))
                 throw new ArgumentException("Not an enumeration type", "enumType");
 
 #if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT
@@ -73,5 +65,14 @@ namespace Org.BouncyCastle.Utilities
             int pos = (int)(DateTimeUtilities.CurrentUnixMs() & int.MaxValue) % values.Length;
             return (Enum)values.GetValue(pos);
         }
+
+        internal static bool IsEnumType(System.Type t)
+        {
+#if NEW_REFLECTION
+            return t.GetTypeInfo().IsEnum;
+#else
+            return t.IsEnum;
+#endif
+        }
     }
 }
diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs
index 361fe7536..86484854d 100644
--- a/crypto/src/util/Platform.cs
+++ b/crypto/src/util/Platform.cs
@@ -220,5 +220,10 @@ namespace Org.BouncyCastle.Utilities
         {
             return InvariantCompareInfo.IsSuffix(source, suffix, CompareOptions.Ordinal);
         }
+
+        internal static string GetTypeName(object obj)
+        {
+            return obj.GetType().FullName;
+        }
     }
 }