Exemplo n.º 1
0
        /// <summary>
        /// 异步post请求,返回指定的类型
        /// 支持的返回类型:string,BitmapImage,byte[]
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="body">网络请求报文体</param>
        /// <returns></returns>
        public static async Task <T> PostAsync <T>(this NetworkRequest source, string body = null) where T : class
        {
            byte[] bytes = await source.PostAsync(body);

            return(await TypeConvertAsync <T>(bytes));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 异步get请求,返回指定的类型
        /// 支持的返回类型:string,BitmapImage,byte[]
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static async Task <T> GetAsync <T>(this NetworkRequest source) where T : class
        {
            byte[] bytes = await source.GetAsync();

            return(await TypeConvertAsync <T>(bytes));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 同步post请求,返回指定的类型 此方法会阻塞调用线程
 /// 支持的返回类型:string,BitmapImage,byte[]
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <param name="body">网络请求报文体</param>
 /// <returns></returns>
 public static T Post <T>(this NetworkRequest source, string body = null) where T : class
 {
     byte[] bytes = source.Post(body);
     return(TypeConvertAsync <T>(bytes).Result);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 同步Get请求 返回指定的类型 此方法会阻塞调用线程
 /// 支持的返回类型:string,BitmapImage,byte[]
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 public static T Get <T>(this NetworkRequest source) where T : class
 {
     byte[] bytes = source.Get();
     return(TypeConvertAsync <T>(bytes).Result);
 }