summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-11-08 18:40:10 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-11-08 18:40:10 +0700
commitcebeeb6d6573e15fe4f1a834f77ead9e8556f570 (patch)
tree8b5bd79075ce8f4c95c1357777da3852201afc0c /crypto/src
parentSome more PORTABLE updates (diff)
downloadBouncyCastle.NET-ed25519-cebeeb6d6573e15fe4f1a834f77ead9e8556f570.tar.xz
A few more changes to sync up with BouncyCastle-PCL
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/asn1/DerGeneralizedTime.cs4
-rw-r--r--crypto/src/asn1/DerUTCTime.cs4
-rw-r--r--crypto/src/asn1/x509/Time.cs4
-rw-r--r--crypto/src/util/Enums.cs10
-rw-r--r--crypto/src/util/Platform.cs2
-rw-r--r--crypto/src/util/TypeExtensions.cs17
6 files changed, 40 insertions, 1 deletions
diff --git a/crypto/src/asn1/DerGeneralizedTime.cs b/crypto/src/asn1/DerGeneralizedTime.cs
index 152596678..17c42e7cf 100644
--- a/crypto/src/asn1/DerGeneralizedTime.cs
+++ b/crypto/src/asn1/DerGeneralizedTime.cs
@@ -83,7 +83,11 @@ namespace Org.BouncyCastle.Asn1
         public DerGeneralizedTime(
             DateTime time)
         {
+#if PORTABLE
+            this.time = time.ToUniversalTime().ToString(@"yyyyMMddHHmmss\Z");
+#else
             this.time = time.ToString(@"yyyyMMddHHmmss\Z");
+#endif
         }
 
         internal DerGeneralizedTime(
diff --git a/crypto/src/asn1/DerUTCTime.cs b/crypto/src/asn1/DerUTCTime.cs
index ab8ca792d..639a2d4f4 100644
--- a/crypto/src/asn1/DerUTCTime.cs
+++ b/crypto/src/asn1/DerUTCTime.cs
@@ -86,7 +86,11 @@ namespace Org.BouncyCastle.Asn1
         public DerUtcTime(
             DateTime time)
         {
+#if PORTABLE
+            this.time = time.ToUniversalTime().ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+#else
             this.time = time.ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+#endif
         }
 
         internal DerUtcTime(
diff --git a/crypto/src/asn1/x509/Time.cs b/crypto/src/asn1/x509/Time.cs
index 8350339bb..ffe293521 100644
--- a/crypto/src/asn1/x509/Time.cs
+++ b/crypto/src/asn1/x509/Time.cs
@@ -34,7 +34,11 @@ namespace Org.BouncyCastle.Asn1.X509
         public Time(
             DateTime date)
         {
+#if PORTABLE
+            string d = date.ToUniversalTime().ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+#else
             string d = date.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+#endif
 
             int year = int.Parse(d.Substring(0, 4));
 
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