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

修复 GetMethodInfo 方法重载调用 修改

parent cac989ca
......@@ -333,27 +333,25 @@ namespace FObjBase.Reflect
foreach (var methodInfo in methodInfos)
{
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;
//比较 names 与 names_data
var exps_req = names_req.Except(names);
if (exps_req.Count() != 0)
{
//请求的参数,这个method 不是全部都有
continue;
}
var exps = names.Except(names_req);
if (exps.Count() == 2 && exps.Contains("asyncDelegate") && exps.Contains("asyncContext"))
{
//请求的参数 就只有 "asyncDelegate" 与 "asyncContext" 没有而已
//这个就是需要调用的 method
return methodInfo;
}
else
{
continue;
}
if (names.Count() != names_req.Count())
continue;//数量不一致,肯定不同
var sames = names_req.Intersect(names);
if (sames.Count() != names_req.Count())
continue;// names 与 names_req 的交集数量与names_req不一样,肯定不同
//就是它
return methodInfo;
}
return null;
}
......
......@@ -330,6 +330,10 @@ namespace FObjBase.Reflect
//触发事件!!!
var methodInfo = GetType().GetMethod(anyEvent.triggerName);
if (methodInfo == null)
{
throw new Exception($"客户端 {GetType()} 忘记写 {anyEvent.triggerName}");
}
var obj = rData.data.ToObject(anyEvent.retType);
//出错,就提示,肯定是客户端忘记写 "Trigger_XXXX"
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