public RpcMethodInfo FindMethod(bool isStatic, object[] parametersObjects) { var parameters = GetTypesParameters(parametersObjects); if (_commonMethods.TryGetValue(parameters.Length, out var methodsList)) { if (parameters.Length == 0) { var method = methodsList[0]; if (!method.IsGeneric && isStatic == method.Method.IsStatic) { return(method); } return(null); } foreach (var method in methodsList) { if (!method.IsGeneric && isStatic == method.Method.IsStatic && method.Compare(parameters)) { return(method); } } } foreach (var method in _methodsParams) { if (!method.IsGeneric && isStatic == method.Method.IsStatic && method.CompareParams(parameters)) { return(method); } if (method.IsGeneric && isStatic == method.Method.IsStatic) { var methodInfo = method.GenericMethod.GetRealMethodsParams(parameters, method); var res = new RpcMethodInfo(methodInfo); if (res.CompareParams(parameters)) { return(res); } } } if (methodsList != null) { var res = FindGenericMethod(isStatic, methodsList, parameters); if (res != null) { return(res); } } // AutoWrap.СообщитьОбОшибке("Метод существует но не подходят parametersObjects"); return(null); }
public RpcMethodInfo FindGenericMethod(bool isStatic, Type[] genericParameters, Type[] methodParameters) { if (_commonMethods.TryGetValue(methodParameters.Length, out var methodList)) { foreach (var method in methodList) { if (method.IsGeneric && isStatic == method.Method.IsStatic) { // var MethodInfo = метод.GenericMethod.GetRealMethod(genericParameters, methodParameters); var methodInfo = method.GenericMethod.MethodInfo.MakeGenericMethod(genericParameters); { var res = new RpcMethodInfo(methodInfo); if (res.Compare(methodParameters)) { return(res); } } } } } foreach (var method in _methodsParams) { if (method.IsGeneric && isStatic == method.Method.IsStatic) { var methodInfo = method.GenericMethod.MethodInfo.MakeGenericMethod(genericParameters);// метод.GenericMethod.GetRealMethod(genericParameters, methodParameters); { var res = new RpcMethodInfo(methodInfo); if (res.CompareParams(methodParameters)) { return(res); } } } } return(null); }