Ejemplo n.º 1
0
 public static MyHttpClient GetInstance()
 {
     if (null == _instance)
     {
         _instance = new MyHttpClient();
     }
     return(_instance);
 }
Ejemplo n.º 2
0
        public static string InvokePostByHttpUtil(string url, MyFormUrlEncodedContent parameters)
        {
            MyHttpClient myHttpClient           = MyHttpClient.GetInstance();
            Task <HttpResponseMessage> task     = myHttpClient.PostAsync(url, parameters);
            HttpResponseMessage        response = task.Result;
            var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

            return(result);
        }
Ejemplo n.º 3
0
        public static string InvokeGetByHttpUtil(string url)
        {
            MyHttpClient myHttpClient = MyHttpClient.GetInstance();

            Task <HttpResponseMessage> task     = myHttpClient.GetAsync(url);
            HttpResponseMessage        response = task.Result;
            var result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

            return(result);
        }
Ejemplo n.º 4
0
 public new static void Dispose()
 {
     ((HttpMessageInvoker)_instance)?.Dispose();
     _instance = null;
 }
Ejemplo n.º 5
0
 public static void Dispose()
 {
     MyHttpClient.Dispose();
 }