Commit 73454d5d authored by 潘栩锋's avatar 潘栩锋 🚴

修复 GetMethodInfo 方法重载调用 修改

parent cac989ca
...@@ -333,27 +333,25 @@ namespace FObjBase.Reflect ...@@ -333,27 +333,25 @@ namespace FObjBase.Reflect
foreach (var methodInfo in methodInfos) foreach (var methodInfo in methodInfos)
{ {
var parameterInfos = methodInfo.GetParameters(); var parameterInfos = methodInfo.GetParameters();
var names = parameterInfos.Select(pi => pi.Name); //全部参数名称
var names = parameterInfos.Select(pi => pi.Name).ToList();
//删除掉 asyncDelegate,asyncContext
names.Remove("asyncDelegate");
names.Remove("asyncContext");
var names_req = parameterNames; var names_req = parameterNames;
//比较 names 与 names_data
var exps_req = names_req.Except(names); if (names.Count() != names_req.Count())
if (exps_req.Count() != 0) continue;//数量不一致,肯定不同
{
//请求的参数,这个method 不是全部都有 var sames = names_req.Intersect(names);
continue;
} if (sames.Count() != names_req.Count())
var exps = names.Except(names_req); continue;// names 与 names_req 的交集数量与names_req不一样,肯定不同
if (exps.Count() == 2 && exps.Contains("asyncDelegate") && exps.Contains("asyncContext"))
{ //就是它
//请求的参数 就只有 "asyncDelegate" 与 "asyncContext" 没有而已 return methodInfo;
//这个就是需要调用的 method
return methodInfo;
}
else
{
continue;
}
} }
return null; return null;
} }
......
...@@ -330,6 +330,10 @@ namespace FObjBase.Reflect ...@@ -330,6 +330,10 @@ namespace FObjBase.Reflect
//触发事件!!! //触发事件!!!
var methodInfo = GetType().GetMethod(anyEvent.triggerName); var methodInfo = GetType().GetMethod(anyEvent.triggerName);
if (methodInfo == null)
{
throw new Exception($"客户端 {GetType()} 忘记写 {anyEvent.triggerName}");
}
var obj = rData.data.ToObject(anyEvent.retType); var obj = rData.data.ToObject(anyEvent.retType);
//出错,就提示,肯定是客户端忘记写 "Trigger_XXXX" //出错,就提示,肯定是客户端忘记写 "Trigger_XXXX"
methodInfo.Invoke(this, new object[] { obj }); methodInfo.Invoke(this, new object[] { obj });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment