Beispiel #1
0
        private static void GetRecieve <T>(HttpWebRequest request, RequestData <T> data) where T : BaseRes
        {
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (var responseStream = response.GetResponseStream())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    StreamReader reader = new StreamReader(responseStream);
                    var          str    = reader.ReadToEnd();
                    var          res    = JsonMapper.ToObject <T>(str);

                    var msg = string.Format("Response: {0}", str);
                    Console.WriteLine(msg);
                    InvokeAsync(() =>
                    {
                        data.Callback(res);
                        //TestStringRes(str);
                    });
                }
            }
        }