private static void HandleInvalidInputException(ParameterInfo currentParameterInfo, Method m) { string name = "N/A"; if (currentParameterInfo != null) { name = currentParameterInfo.Name; } m.Error = string.Concat("不正确的输入: ", name); }
public Method AddMethod(string name) { Method r = new Method { Name = name }; Methods.Add(r); return r; }
private static void HandleUnknownException(Method m, Exception err) { m.Error = ErrorHandler.Handle(err).Message; }
private static void HandleInvokeException(MethodInfo currentMethod, Method m) { m.Error = string.Concat("请求的方法调用失败: ", currentMethod.Name); }
private void InvokeJsMethod(ref ParameterInfo currentParameterInfo, Method m, MethodInfo mi) { if (mi != null && mi.IsPublic) { object[] args = m.ToArray(); ParameterInfo[] pis = mi.GetParameters(); if (pis.Length == 1 && args.Length > 1) { args = new object[] {args}; } for (int ii = 0; ii < pis.Length; ii++) { ParameterInfo pi = pis[ii]; currentParameterInfo = pi; Type ptype = pi.ParameterType; Param p = args[ii] as Param; args[ii] = Convert.ChangeType(p == null ? args[ii] : p.Value, ptype); } if (mi.ReturnType != typeof (void)) { m.MethodReturnValue = mi.Invoke(this, args); } else { mi.Invoke(this, args); } } }
private static void HandleInvokeException(MethodInfo currentMethod, Method m) { string name = "N/A"; if (currentMethod != null) { name = currentMethod.Name; } m.Error = string.Concat("请求的方法调用失败: ", currentMethod.Name); }