public override bool Config() { var parameters = Proxy.methodInfo.GetParameters(); Parameters = new ParamInfo[parameters.Length]; for (int i = 0, j = parameters.Length; i < j; i++) { Parameters[i] = new ParamInfo(parameters[i]); } MethodName = Proxy.methodInfo.Name; return true; }
/// <summary> /// 参数类型转换 /// </summary> /// <param name="targetType"></param> /// <param name="o"></param> /// <returns></returns> static object Convert(ParamInfo targetType, object o) { if (o == null) return null; if (o.GetType() == targetType.ParameterType) return o; if (targetType.IsIConvertible) { if (targetType.IsEnum) { return Enum.Parse(targetType.ParameterType, o.ToString(), true); } else { if (o is IConvertible) return System.Convert.ChangeType(o, targetType.ParameterType); else return System.Convert.ChangeType(o.ToString(), targetType.ParameterType); } } else return o; }