internal ObjectRequestParameter GetObjectParameterType(string requestParameter, string actionName, string controllerName) { try { ControllerRegister register = controllerManager.GetControllerRegister(controllerName); Type type = register.Type; MethodInfo method = type.GetMethods().FirstOrDefault(m => m.Name.Equals(actionName)); if (method == null) { return(null); } if (!requestParameter.Contains(".")) { return(null); } string parameter = requestParameter.Substring(0, requestParameter.IndexOf(".")); ParameterInfo parameterInfo = method.GetParameters().FirstOrDefault(p => p.Name.Equals(parameter)); return(new ObjectRequestParameter(parameterInfo.Name, parameterInfo.ParameterType.FullName)); } catch (Exception ex) { logger.WriteLog($"*** CHECK PARAMETER '{requestParameter}' FOR ACTION '{controllerName}.{actionName}' ERROR: *** \n{ex.Message}", controllerName, actionName, ServerLogType.ERROR); return(null); } }
public List <string> GetActionParameters(string controller, string action) { ControllerRegister register = controllerManager.GetControllerRegister(controller); if (register == null) { return(new List <string>()); } MethodInfo method = register.Type.GetMethod(action); if (method == null) { return(new List <string>()); } return(method .GetParameters() .Select(p => p.Name) .ToList()); }