From 8a6249c4a34cf8caf9d0cf6ec3a146f274e1f44a Mon Sep 17 00:00:00 2001 From: Gang Zhuo Date: Sat, 10 Oct 2015 03:34:27 -0400 Subject: [PATCH] revert Newtonsoft.Json --- .../Controller/Strategy/StatisticsStrategy.cs | 3 ++- .../Model/StatisticsStrategyConfiguration.cs | 7 ++++--- shadowsocks-csharp/packages.config | 1 + shadowsocks-csharp/shadowsocks-csharp.csproj | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs index 3a5e1c59..d3b5e26b 100644 --- a/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs +++ b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Threading; +using Newtonsoft.Json; using Shadowsocks.Model; namespace Shadowsocks.Controller.Strategy @@ -65,7 +66,7 @@ namespace Shadowsocks.Controller.Strategy score += statisticsData.MinResponse*factor; if (!config.Calculations.TryGetValue("MaxResponse", out factor)) factor = 0; score += statisticsData.MaxResponse*factor; - Logging.Debug($"{serverName} {SimpleJson.SimpleJson.SerializeObject(statisticsData)}"); + Logging.Debug($"{serverName} {JsonConvert.SerializeObject(statisticsData)}"); return score; } diff --git a/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs b/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs index 1b9ba90b..62a48c2e 100644 --- a/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs +++ b/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs @@ -6,6 +6,7 @@ using System.Reflection; using Shadowsocks.Controller; using Shadowsocks.Controller.Strategy; using SimpleJson; +using Newtonsoft.Json; namespace Shadowsocks.Model { @@ -28,10 +29,10 @@ namespace Shadowsocks.Model try { var content = File.ReadAllText(ConfigFile); - var configuration = SimpleJson.SimpleJson.DeserializeObject(content); + var configuration = JsonConvert.DeserializeObject(content); return configuration; } - catch (FileNotFoundException) + catch (FileNotFoundException e) { var configuration = new StatisticsStrategyConfiguration(); Save(configuration); @@ -48,7 +49,7 @@ namespace Shadowsocks.Model { try { - var content = SimpleJson.SimpleJson.SerializeObject(configuration); + var content = JsonConvert.SerializeObject(configuration, Formatting.Indented); File.WriteAllText(ConfigFile, content); } catch (Exception e) diff --git a/shadowsocks-csharp/packages.config b/shadowsocks-csharp/packages.config index e79d8643..b309fb97 100644 --- a/shadowsocks-csharp/packages.config +++ b/shadowsocks-csharp/packages.config @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index 0ec088a7..423268d8 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -81,6 +81,10 @@ False + + 3rd\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll + True +