/// <summary> /// 返回结果处理 /// </summary> /// <param name="context"></param> /// <returns></returns> protected async override Task <object> GetTaskResult(WebApiClient.Contexts.ApiActionContext context) { var txt = await context.ResponseMessage.Content.ReadAsStringAsync(); if (txt.Contains("status_code")) { var err = (ResultError)context.HttpApiConfig.JsonFormatter.Deserialize(txt, typeof(ResultError)); throw new SeniverserException(err.status_code); } var data = (SeniversResult)context.HttpApiConfig.JsonFormatter.Deserialize(txt, typeof(SeniversResult)); return(ApiRestReulst.True(data)); }
/// <summary> /// 执行api /// </summary> /// <param name="context">上下文</param> /// <returns></returns> public Task Execute(ApiActionContext context) { return(this.ExecuteAsync(context).Cast(this.Return.DataType)); }
/// <summary> /// 执行发送请求 /// </summary> /// <param name="context">上下文</param> /// <returns></returns> private async Task SendAsync(ApiActionContext context) { var invoker = context.HttpApiConfig.HttpClient; context.ResponseMessage = await invoker.SendAsync(context.RequestMessage); }