Commits

HexRx  committed 270da2d

Used SimpleJson instead of Newtonsoft.Json

  • Participants
  • Parent commits 87d3543

Comments (0)

Files changed (2)

File KPDataSave/AccountState.cs

 /*
     KPDataSave - KeePass plugin which saves database in Dropbox service
-    Copyright (C) 2011-2012 HexRx
+    Copyright (C) 2011-2013 HexRx
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 using System.Security.Cryptography;
 using System.Text;
 using KeePass.Plugins;
-using Newtonsoft.Json;
+using RestSharp;
 
 namespace KPDataSave
 {
         {
             // Т.к KeePass сохраняет настройки только при закрытии приложения, необходимо хранить копию в памяти
             _account = this;
-            string json = JsonConvert.SerializeObject(this);
+            string json = SimpleJson.SerializeObject(this);
             var symmetricKey = new RijndaelManaged();
             ICryptoTransform cryptoTransform = symmetricKey.CreateEncryptor(Encoding.UTF8.GetBytes("hhekhlyshoqxt5s"), 
                 Encoding.UTF8.GetBytes("7movlrmyr1txov5e"));
             }
             try
             {
-                _account = JsonConvert.DeserializeObject<AccountState>(dvalue);
+                _account = SimpleJson.DeserializeObject<AccountState>(dvalue);
             }
             // В конфиге пусто
             catch (ArgumentNullException)
                 return null;
             }
             // Неправильные данные для десериализации
-            catch (JsonReaderException)
+            catch (SerializationException)
             {
                 return null;
             }

File KPDataSave/Libs/DropboxAPI/DropboxClient.cs

 /*
     KPDataSave - KeePass plugin which saves database in Dropbox service
-    Copyright (C) 2011-2012 HexRx
+    Copyright (C) 2011-2013 HexRx
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 using RestSharp.Contrib;
 using DropboxAPI.Models;
 using DropboxAPI.Exceptions;
-using Newtonsoft.Json;
 
 namespace DropboxAPI
 {
             request.Resource = "{version}/oauth/request_token";
             request.AddUrlSegment("version", version);
 
-            RestResponse response = client.Execute(request);
+            var response = client.Execute(request);
             // Если нет соединения с инетом
             if (response.StatusCode == 0)
                 throw new DropboxClientException(response.Content, response.StatusCode);
             if (response.StatusCode != HttpStatusCode.OK)
-                throw new DropboxClientException(JsonConvert.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
+                throw new DropboxClientException(SimpleJson.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
 
             // Получаем токены
             NameValueCollection qs = HttpUtility.ParseQueryString(response.Content);
             request.AddUrlSegment("version", version);
             client.Authenticator = OAuth1Authenticator.ForAccessToken(appKey, appSecret, oauth_token, oauth_token_secret);
 
-            RestResponse response = client.Execute(request);
+            var response = client.Execute(request);
             if (response.StatusCode == 0)
                 throw new DropboxClientException(response.Content, response.StatusCode);
             if (response.StatusCode != HttpStatusCode.OK)
-                throw new DropboxClientException(JsonConvert.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
+                throw new DropboxClientException(SimpleJson.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
 
             NameValueCollection qs = HttpUtility.ParseQueryString(response.Content);
             this.AccessToken = new AccessToken();
             request.Resource = "{version}/account/info";
             request.AddUrlSegment("version", version);
 
-            RestResponse<AccountInfo> response = client.Execute<AccountInfo>(request);
+            var response = client.Execute<AccountInfo>(request);
             if (response.StatusCode != HttpStatusCode.OK)
-                throw new DropboxClientException(JsonConvert.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
+                throw new DropboxClientException(SimpleJson.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
 
             return response.Data;
         }
             request.AddParameter("file", localFile.Name);
             request.AddFile("file", content, localFile.Name);
 
-            RestResponse response = client.Execute(request);
+            var response = client.Execute(request);
 
             return response.StatusCode == HttpStatusCode.OK;
         }
             request.AddUrlSegment("version", version);
             request.AddUrlSegment("path", path);
 
-            RestResponse<MetaData> response = client.Execute<MetaData>(request);
+            var response = client.Execute<MetaData>(request);
             // Если в ответе пришла ошибка, генерируем исключение DropboxClientException
             if (response.StatusCode != HttpStatusCode.OK)
-                throw new DropboxClientException(JsonConvert.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
+                throw new DropboxClientException(SimpleJson.DeserializeObject<APIError>(response.Content).Error, response.StatusCode);
 
             return response.Data;
         }