/// <summary> /// 得到方法的最基本的信息 /// </summary> /// <returns></returns> public static CustomMethodInfo GetMethodBaseInfo(MethodPathInfo methodPathInfo, BindingFlags bindingAttr) { CustomMethodInfo customMethodInfo = new CustomMethodInfo(); try { //得到程序集 customMethodInfo.Assembly = Assembly.Load(methodPathInfo.Assembly); //得到类的类型 Type t = customMethodInfo.Assembly.GetType(methodPathInfo.Assembly + "." + methodPathInfo.ClassName, true, true); //得到类的类型 customMethodInfo.ClassType = t; //得到方法 customMethodInfo.Method = t.GetMethod(methodPathInfo.MethodName, bindingAttr); if (customMethodInfo.Method == null) { //没有得到方法 把整个信息置空 customMethodInfo = null; } } catch { throw; } return(customMethodInfo); }
/// <summary> /// 得到方法的一些基本的路径信息 /// </summary> /// <param name="virtualPath"></param> /// <returns></returns> public static MethodPathInfo GetMethodPathInfo(string virtualPath) { MethodPathInfo methodPathInfo = null; //正则判断 Match match = Regex.Match(virtualPath, REGEX_TEXT, RegexOptions.IgnoreCase); //如果匹配到了 if (match.Success) { //取出class和method methodPathInfo = new MethodPathInfo(); methodPathInfo.ClassName = match.Groups["classname"].Value; methodPathInfo.MethodName = match.Groups["methodname"].Value; methodPathInfo.Assembly = ASSEMBLY; } return methodPathInfo; }
/// <summary> /// 得到方法的一些基本的路径信息 /// </summary> /// <param name="virtualPath"></param> /// <returns></returns> public static MethodPathInfo GetMethodPathInfo(string virtualPath) { MethodPathInfo methodPathInfo = null; //正则判断 Match match = Regex.Match(virtualPath, REGEX_TEXT, RegexOptions.IgnoreCase); //如果匹配到了 if (match.Success) { //取出class和method methodPathInfo = new MethodPathInfo(); methodPathInfo.ClassName = match.Groups["classname"].Value; methodPathInfo.MethodName = match.Groups["methodname"].Value; methodPathInfo.Assembly = ASSEMBLY; } return(methodPathInfo); }
/// <summary> /// 构造函数 /// </summary> /// <param name="context">当前上下文</param> /// <param name="methodPathInfo">方法的相关路径信息</param> public MethodHelper(HttpContext context, MethodPathInfo methodPathInfo) { if (context == null) { throw new AjaxException("没有得到当前上下文"); } else { this._context = context; } if (methodPathInfo.IsValidate) { this._methodPathInfo = methodPathInfo; } else { throw new ArgumentNullException("参数不能为空"); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="context">当前上下文</param> /// <param name="methodPathInfo">方法的相关路径信息</param> public MethodHelper(HttpContext context,MethodPathInfo methodPathInfo) { object obj = context.Session; object obj2 = System.Web.HttpContext.Current.Session; if (context == null) { throw new AjaxException("没有得到当前上下文"); } else { this._context = context; } if (methodPathInfo.IsValidate) { this._methodPathInfo = methodPathInfo; } else { throw new ArgumentNullException("参数不能为空"); } }
/// <summary> /// 构造方法 主要是初始化请求方法的一些路径信息 比如 空间 类 方法名 /// </summary> ///<param name="virtualPath">请求的一个虚拟路径</param> public ResponseHandler(string virtualPath) { this.CurrentMethodPathInfo = UrlConfig.GetMethodPathInfo(virtualPath); }