diff options
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 | 18 | ||||
-rw-r--r-- | crypto/src/util/zlib/ZDeflaterOutputStream.cs | 2 |
4 files changed, 30 insertions, 2 deletions
diff --git a/crypto/src/util/Enums.cs b/crypto/src/util/Enums.cs index 25b218667..20b978c22 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 && !PORTABLE 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..c7ce807a0 --- /dev/null +++ b/crypto/src/util/TypeExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Reflection; + +#if NEW_REFLECTION + +namespace Org.BouncyCastle +{ + internal static class TypeExtensions + { + public static bool IsInstanceOfType(this Type type, object instance) + { + return instance != null && type.GetTypeInfo().IsAssignableFrom(instance.GetType().GetTypeInfo()); + } + } + +} + +#endif \ No newline at end of file diff --git a/crypto/src/util/zlib/ZDeflaterOutputStream.cs b/crypto/src/util/zlib/ZDeflaterOutputStream.cs index d0f0bcb8d..d0978942a 100644 --- a/crypto/src/util/zlib/ZDeflaterOutputStream.cs +++ b/crypto/src/util/zlib/ZDeflaterOutputStream.cs @@ -135,7 +135,7 @@ namespace Org.BouncyCastle.Utilities.Zlib { z.free(); z=null; } - + #if PORTABLE protected override void Dispose(bool disposing) { |