Example #1
0
        public async Task <TObj> GetAllAsync <TObj>() where TObj : class
        {
            IDictionary <string, string> pairs = new Dictionary <string, string>();
            SDKResult result = await client.GetAsync("GetAll", pairs);

            JObject obj = JsonConvert.DeserializeObject <JObject>(result.Result);

            if (result.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                ErrorMsg = obj["errorMsg"].ToString();
                return(null);
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <TObj>(obj["data"] == null?"": obj["data"].ToString()));
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.NoContent)
            {
                return(default(TObj));
            }
            else
            {
                throw new ApplicationException("未知的错误");
            }
        }