public override void Verify <RequestModelType, ResponseModelType>(ApiMethodBase <RequestModelType, ResponseModelType> apiMethodBase, RequestModelType request) { string configMethod = apiMethodBase.ApiMethodMetaInfo.APIMethodDesc.HttpMethodType.ToString().ToUpper(); string currentMethod = apiMethodBase.HttpMethod.ToUpper(); bool flag = false; if (configMethod == HttpMethodType.ALL.ToString()) { flag = true; } else { flag = currentMethod == apiMethodBase.ApiMethodMetaInfo.APIMethodDesc.HttpMethodType.ToString().ToUpper(); } if (flag == false) { throw new ApiException(ApiResultCode.HttpMethodError) { ErrorMessage = string.Format("该接口必须以:{0}方式请求", configMethod) }; } }
public async static Task PostAsync(this ApiMethodBase method) { var response = await WebHelper.HttpPostAsync(method.Parameters); XmlHelper.Validate(response); }
/// <summary> /// 执行验证 /// </summary> /// <param name="apiMethodBase"></param> public abstract void Verify <RequestModelType, ResponseModelType>(ApiMethodBase <RequestModelType, ResponseModelType> apiMethodBase, RequestModelType request) where RequestModelType : ApiRequestModelBase where ResponseModelType : ApiResponseModelBase;
public async static Task <TResult> GetResultAsync <TResult>(this ApiMethodBase <TResult> method) { var response = await WebHelper.HttpGetAsync(method.Parameters); return(method.ParseResult(XmlHelper.Validate(response))); }