/// <summary> /// 【外部接口】用于根据服务的类名和方法名执行某个请求 /// </summary> /// <param name="context"></param> /// <param name="pair"></param> public static void ProcessRequest(HttpContext context, NamesPair pair) { if (context == null) { throw new ArgumentNullException("context"); } if (pair == null) { throw new ArgumentNullException("pair"); } if (string.IsNullOrEmpty(pair.ServiceName) || string.IsNullOrEmpty(pair.MethodName)) { ExceptionHelper.Throw404Exception(context); } InvokeInfo vkInfo = ReflectionHelper.GetInvokeInfo(pair); if (vkInfo == null) { ExceptionHelper.Throw404Exception(context); } ServiceInfo info = new ServiceInfo(pair, vkInfo); ProcessRequest(context, info); }
/// <summary> /// 根据类型名称以及方法名称返回要调用的相关信息 /// </summary> /// <param name="pair">包含类型名称以及方法名称的对象</param> /// <returns></returns> public static InvokeInfo GetInvokeInfo(NamesPair pair) { if (pair == null) { throw new ArgumentNullException("pair"); } InvokeInfo vkInfo = new InvokeInfo(); vkInfo.ServiceTypeInfo = GetServiceType(pair.ServiceName); if (vkInfo.ServiceTypeInfo == null) { return(null); } vkInfo.MethodAttrInfo = GetServiceMethod(vkInfo.ServiceTypeInfo.ServiceType, pair.MethodName); if (vkInfo.MethodAttrInfo == null) { return(null); } if (vkInfo.MethodAttrInfo.MethodInfo.IsStatic == false) { vkInfo.ServiceInstance = Activator.CreateInstance(vkInfo.ServiceTypeInfo.ServiceType); } return(vkInfo); }
public ServiceInfo(NamesPair pair, InvokeInfo vkInfo) { if (pair == null) { throw new ArgumentNullException("pair"); } if (vkInfo == null) { throw new ArgumentNullException("vkInfo"); } NamesPair = pair; InvokeInfo = vkInfo; }