Browse Source

compat

tags/2.3
clowwindy 10 years ago
parent
commit
0a21d8a4ae
3 changed files with 16 additions and 6 deletions
  1. +14
    -4
      shadowsocks-csharp/Model/Configuration.cs
  2. +1
    -1
      shadowsocks-csharp/shadowsocks-csharp.csproj
  3. +1
    -1
      shadowsocks-csharp/simple-json

+ 14
- 4
shadowsocks-csharp/Model/Configuration.cs View File

@@ -43,11 +43,8 @@ namespace shadowsocks_csharp.Model
{
try
{
var json = "[0,1,2]";
var result = SimpleJson.SimpleJson.DeserializeObject<List<int>>(json);
string configContent = File.ReadAllText(CONFIG_FILE);
Configuration config = SimpleJson.SimpleJson.DeserializeObject<Configuration>(configContent);
Configuration config = SimpleJson.SimpleJson.DeserializeObject<Configuration>(configContent, new JsonSerializerStrategy());
config.isDefault = false;
return config;
}
@@ -129,5 +126,18 @@ namespace shadowsocks_csharp.Model
throw new ArgumentException("server can not be blank");
}
}
private class JsonSerializerStrategy : SimpleJson.PocoJsonSerializerStrategy
{
// convert string to int
public override object DeserializeObject(object value, Type type)
{
if (type == typeof(Int32) && value.GetType() == typeof(string))
{
return Int32.Parse(value.ToString());
}
return base.DeserializeObject(value, type);
}
}
}
}

+ 1
- 1
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -60,7 +60,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DefineConstants>TRACE;DEBUG;SIMPLE_JSON_REFLECTIONEMIT</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>


+ 1
- 1
shadowsocks-csharp/simple-json

@@ -1 +1 @@
Subproject commit 663c62a77ab3318f04ddb9449b2b882364709625
Subproject commit 6b632fd304736788227e709b87e5bcf59bb4911d

Loading…
Cancel
Save