/// <summary> /// 根据方法名称,返回内部表示的调用信息。 /// </summary> /// <param name="name"></param> /// <returns></returns> public static InvokeInfo GetActionInvokeInfo(string name) { if (s_PageActionDict == null || s_PageActionDict.Count <= 0) { InitControllers(); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } ActionDescription action = null; if (s_PageActionDict.TryGetValue(name, out action) == false) { return(null); } InvokeInfo vkInfo = new InvokeInfo(); vkInfo.Business = action.Business; vkInfo.Action = action; if (vkInfo.Action.MethodInfo.IsStatic == false) { //vkInfo.Instance = Activator.CreateInstance(vkInfo.Controller.ControllerType); vkInfo.Instance = vkInfo.Business.BusinessType.FastNew(); } return(vkInfo); }
private static object[] GetActionCallParameters(string _DataContent, ActionDescription action) { if (action.Parameters == null || action.Parameters.Length == 0) { return(null); } return(GetParameters(_DataContent, action)); }
private static object[] GetActionCallParameters(BaseParam param, ActionDescription action) { if (action.Parameters == null || action.Parameters.Length == 0) { return(null); } return(GetParameters(param, action)); }
public static object[] GetParameters(BaseParam param, ActionDescription action) { if (action == null) { throw new ArgumentNullException("action"); } object[] parameters = new object[action.Parameters.Length]; for (int i = 0; i < action.Parameters.Length; i++) { ParameterInfo p = action.Parameters[i]; if (p.IsOut) { continue; } if (p.ParameterType == typeof(VoidType)) { continue; } Type paramterType = p.ParameterType.GetRealType(); // 如果参数是可支持的类型,则直接从HttpRequest中读取并赋值 if (paramterType.IsSupportableType()) { //var a = param[""]; object val = GetValue(param, p.Name); if (val != null) { parameters[i] = val; } else { if (p.ParameterType.IsValueType && p.ParameterType.IsNullableType() == false) { throw new ArgumentException("未能找到指定的参数值:" + p.Name); } } } else { throw new ArgumentException("暂不支持该类型:" + p.ParameterType.ToString()); //ModelHelper.FillModel(request, item, p.Name); //parameters[i] = Convert.ChangeType(item, paramterType); //parameters[i] = item; //parameters[i] = null; } } return(parameters); }
public static object[] GetParameters(string _DataContent, ActionDescription action) { if (action == null) { throw new ArgumentNullException("action"); } var meths = action.Parameters; Object[] params_obj = new Object[meths.Length]; for (int i = 0; i < meths.Length; i++) { var mtype = meths[i].Name; if (mtype == "json") { params_obj[i] = _DataContent; continue; } if (meths[i].IsOut) { continue; } if (meths[i].ParameterType == typeof(VoidType)) { continue; } var value = GetValue(_DataContent, mtype); if (value == null) { throw new ArgumentException("为讲对象引用到实例,参数:" + mtype); } string val = value.ToString(); Type ptype = meths[i].ParameterType; // 如果参数是可支持的类型,则直接从HttpRequest中读取并赋值 if (ptype.GetRealType().IsSupportableType()) { params_obj[i] = Convert.ChangeType(val, ptype); } else { params_obj[i] = JsonConvert.DeserializeObject(val, ptype); } } return(params_obj); }