cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] cordova-plugin-file-transfer git commit: Check for the existence of Json.net assembly to determin how we deserialize our headers.
Date Fri, 15 May 2015 00:26:57 GMT
Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/master 82b089bc9 -> 72a5d951a


Check for the existence of Json.net assembly to determin how we deserialize our headers.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/907e1cdb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/907e1cdb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/907e1cdb

Branch: refs/heads/master
Commit: 907e1cdb138c420227c9e597868562dbeb861556
Parents: 82b089b
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Thu May 14 17:21:40 2015 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Thu May 14 17:21:40 2015 -0700

----------------------------------------------------------------------
 src/wp/FileTransfer.cs | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/907e1cdb/src/wp/FileTransfer.cs
----------------------------------------------------------------------
diff --git a/src/wp/FileTransfer.cs b/src/wp/FileTransfer.cs
index c74738e..675690f 100644
--- a/src/wp/FileTransfer.cs
+++ b/src/wp/FileTransfer.cs
@@ -94,6 +94,8 @@ namespace WPCordovaClassLib.Cordova.Commands
         // NOTE: Any access to this object needs to occur on the UI thread via the Dispatcher
         private WebBrowser browser;
 
+
+
         /// <summary>
         /// Uploading response info
         /// </summary>
@@ -230,6 +232,20 @@ namespace WPCordovaClassLib.Cordova.Commands
             public string Value;
         }
 
+        protected static bool HasJsonDotNet = false;
+        public FileTransfer()
+        {
+            // look for Newtonsoft.Json availability
+            foreach(System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()
)
+            {
+                if (assembly.GetType("Newtonsoft.Json.ConstructorHandling") != null)
+                {
+                    FileTransfer.HasJsonDotNet = true;
+                    break;
+                }
+            }
+        }
+
         /// Helper method to copy all relevant cookies from the WebBrowser control into a
header on
         /// the HttpWebRequest
         /// </summary>
@@ -411,8 +427,16 @@ namespace WPCordovaClassLib.Cordova.Commands
         {
             try
             {
-                return JsonHelper.Deserialize<Header[]>(jsonHeaders)
-                    .ToDictionary(header => header.Name, header => header.Value);
+                if (FileTransfer.HasJsonDotNet)
+                {
+                    return JsonHelper.Deserialize<Header[]>(jsonHeaders,true)
+                        .ToDictionary(header => header.Name, header => header.Value);
+                }
+                else
+                {
+                    return JsonHelper.Deserialize<Header[]>(jsonHeaders)
+                        .ToDictionary(header => header.Name, header => header.Value);
+                }
             }
             catch (Exception)
             {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message