diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-08 18:40:10 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-08 18:40:10 +0700 |
commit | cebeeb6d6573e15fe4f1a834f77ead9e8556f570 (patch) | |
tree | 8b5bd79075ce8f4c95c1357777da3852201afc0c /crypto/src/util | |
parent | Some more PORTABLE updates (diff) | |
download | BouncyCastle.NET-ed25519-cebeeb6d6573e15fe4f1a834f77ead9e8556f570.tar.xz |
A few more changes to sync up with BouncyCastle-PCL
Diffstat (limited to 'crypto/src/util')
-rw-r--r-- | crypto/src/util/Enums.cs | 10 | ||||
-rw-r--r-- | crypto/src/util/Platform.cs | 2 | ||||
-rw-r--r-- | crypto/src/util/TypeExtensions.cs | 17 |
3 files changed, 28 insertions, 1 deletions
diff --git a/crypto/src/util/Enums.cs b/crypto/src/util/Enums.cs index 25b218667..660bbe73f 100644 --- a/crypto/src/util/Enums.cs +++ b/crypto/src/util/Enums.cs @@ -14,7 +14,11 @@ 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 throw new ArgumentException("Not an enumeration type", "enumType"); // We only want to parse single named constants @@ -39,10 +43,14 @@ namespace Org.BouncyCastle.Utilities internal static Array GetEnumValues(System.Type enumType) { +#if NEW_REFLECTION + if (!enumType.GetTypeInfo().IsEnum) +#else if (!enumType.IsEnum) +#endif throw new ArgumentException("Not an enumeration type", "enumType"); -#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE +#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT IList result = Platform.CreateArrayList(); FieldInfo[] fields = enumType.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo field in fields) diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs index 82446b296..d4b18f182 100644 --- a/crypto/src/util/Platform.cs +++ b/crypto/src/util/Platform.cs @@ -34,6 +34,8 @@ namespace Org.BouncyCastle.Utilities { #if SILVERLIGHT return String.Compare(a, b, StringComparison.InvariantCultureIgnoreCase); +#elif SYS_RUNTIME + return String.Compare(a, b, StringComparison.OrdinalIgnoreCase); #elif PORTABLE return String.Compare(a, b, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); #else diff --git a/crypto/src/util/TypeExtensions.cs b/crypto/src/util/TypeExtensions.cs new file mode 100644 index 000000000..203d0a605 --- /dev/null +++ b/crypto/src/util/TypeExtensions.cs @@ -0,0 +1,17 @@ +#if NEW_REFLECTION + +using System; +using System.Reflection; + +namespace Org.BouncyCastle.Utilities +{ + internal static class TypeExtensions + { + public static bool IsInstanceOfType(this Type type, object instance) + { + return instance != null && type.GetTypeInfo().IsAssignableFrom(instance.GetType().GetTypeInfo()); + } + } +} + +#endif |