1. string method = Request["METHAD"];
2. string ClassNamespace = method.Substring(0, method.LastIndexOf("."));// "Bss.Web.Login";
3. object objType = CreateObject(Request["DLL"], ClassNamespace);
4. Type ht = objType.GetType();
5. MethodInfo methodInfo = ht.GetMethod(method.Substring(method.LastIndexOf(".") + 1));
6. int length = Request.Form.AllKeys.Length;
7. ParameterInfo[] paramsInfo = methodInfo.GetParameters();//得到指定方法的参数列表
8.
9. object[] obj = new object[length];
10. for (int i = 0; i < length; i++)
11. {
12. Type tType = paramsInfo[i].ParameterType;
13. //如果它是值类型,或者String
14. if (tType.Equals(typeof(string)) || (!tType.IsInterface && !tType.IsClass))
15. {
16. //改变参数类型
17. obj[i] = Convert.ChangeType(Request.Form[i], tType);
18. }
19. else if (tType.IsClass)//如果是类,将它的json字符串转换成对象
20. {
21. obj[i] = Newtonsoft.Json.JsonConvert.DeserializeObject(Request.Form[i], tType);
22. }
23. }
24. //执行方法
25. object returnValue = methodInfo.Invoke(objType, obj);