Skip to content

Commit c6a0a8a

Browse files
author
magiclu550
committed
[proxy] fix a bug about map: field
1 parent 6c738e3 commit c6a0a8a

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

jsmod2/NetworkHandler.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
228228
{
229229
if (mapper.ContainsKey("field"))//field
230230
{
231-
PropertyInfo info = type.GetProperty("field");
231+
PropertyInfo info = type.GetProperty(mapper["field"]);
232232
if (info != null)
233233
{
234234
//两种情况 读写
@@ -241,9 +241,9 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
241241
}
242242
else
243243
{
244-
if (Utils.isCommon(info.PropertyType))
244+
if (isCommon(info.PropertyType))
245245
{
246-
info.SetValue(map,Utils.getTypeValue(mapper["value"]));
246+
info.SetValue(map,getTypeValue(mapper["value"]));
247247
}
248248

249249
}
@@ -255,13 +255,17 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
255255
//获得值
256256
//字段只支持普通值
257257
object obj = info.GetValue(map);
258-
if (Utils.isCommon(obj.GetType()))
258+
if (isCommon(obj.GetType()))
259259
{
260-
return Utils.getOne(mapper["id"], obj, null);
260+
return getOne(mapper["id"], obj, null);
261261
}
262262
else
263263
{
264-
return Utils.getOne(mapper["id"], obj, null);
264+
//这地方不支持其他值
265+
if (obj.GetType().IsSubclassOf(typeof(Enum)))
266+
return getOne(mapper["id"], obj, null);
267+
else
268+
return getOne(mapper["id"], obj, null);
265269
}
266270
}
267271
}
@@ -280,13 +284,14 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
280284
ParameterInfo[] infos = info.GetParameters();
281285
for (int i = 0; i < args.Length; i++)
282286
{
283-
if (Utils.isCommon(infos[i].ParameterType))
287+
if (isCommon(infos[i].ParameterType))
284288
{
285-
objs[i] = Utils.getTypeValue(args[i]);//针对于普通值
289+
objs[i] = getTypeValue(args[i]);//针对于普通值
286290
}
287291
else
288292
{
289-
if (infos[i].ParameterType == typeof(Player))
293+
//如果不是enum的子类,那么就是api类型
294+
if (!infos[i].ParameterType.IsSubclassOf(typeof(Enum)))
290295
{
291296
objs[i] = ProxyHandler.handler.apiMapping[args[i]];//转换玩家对象
292297
}
@@ -306,14 +311,14 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
306311
//有返回值
307312
if (mapper.ContainsKey("read"))
308313
{
309-
if (Utils.isCommon(info.ReturnType))
314+
if (isCommon(info.ReturnType))
310315
{
311-
return Utils.getOne(mapper["id"],obj,null);//普通值
316+
return getOne(mapper["id"],obj,null);//普通值
312317
}
313318

314319
if (obj is Enum)
315320
{
316-
return Utils.getOne(mapper["id"], obj, null);//枚举值
321+
return getOne(mapper["id"], obj, null);//枚举值
317322
}
318323
//特殊对象
319324
if (obj is List<Item>)
@@ -330,7 +335,7 @@ public static JsonSetting[] invoke(object map, Type type,Dictionary<string,strin
330335
if (obj is List<Vector> || obj is Dictionary<Vector,Vector>)
331336
{
332337

333-
return Utils.getOne(mapper["id"],obj,null);
338+
return getOne(mapper["id"],obj,null);
334339
}
335340

336341
if (obj is List<Door>)

jsmod2/bin/Debug/jsmod2.pdb

16 Bytes
Binary file not shown.

jsmod2/obj/Debug/jsmod2.pdb

16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)