Skip to content

Commit 020161d

Browse files
author
magiclu550
committed
[proxy] fix a bug
1 parent 7cc29ad commit 020161d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

jsmod2/NetworkHandler.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Net.Sockets;
4+
using System.Reflection;
45
using jsmod2;
56
using jsmod2.command;
67
using Newtonsoft.Json;
@@ -241,7 +242,17 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
241242
Type type = api.GetType();
242243
if (mapper["id"].Equals("180"))//180 Get
243244
{
244-
object obj = type.GetField(mapper["field"]).GetValue(api);
245+
PropertyInfo info = type.GetProperty(mapper["field"]);
246+
object obj;
247+
if (info != null)
248+
{
249+
obj = info.GetValue(api);
250+
}
251+
else
252+
{
253+
return null;
254+
}
255+
245256
Type returnType = obj.GetType();
246257
bool isCommonType = returnType == typeof(string) || returnType == typeof(bool) ||
247258
returnType == typeof(float)
@@ -263,7 +274,11 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
263274
{
264275
result = ProxyHandler.handler.apiMapping[val];
265276
}
266-
type.GetField(fieldName).SetValue(api,result);
277+
PropertyInfo info2 = type.GetProperty(fieldName);
278+
if (info2 != null)
279+
{
280+
info2.SetValue(api,result);
281+
}
267282
return null;
268283
}
269284
}

0 commit comments

Comments
 (0)