Пример #1
0
        protected virtual void ProcessResponse(
            MvxRestRequest restRequest,
            HttpWebRequest httpRequest,
            Action <MvxStreamRestResponse> successAction,
            Action <Exception> errorAction)
        {
            httpRequest.BeginGetResponse(result =>
                                         TryCatch(() =>
            {
                var response = (HttpWebResponse)httpRequest.EndGetResponse(result);

                var code = response.StatusCode;

                using (var responseStream = response.GetResponseStream())
                {
                    var restResponse = new MvxStreamRestResponse
                    {
                        CookieCollection = response.Cookies,
                        Stream           = responseStream,
                        Tag        = restRequest.Tag,
                        StatusCode = code
                    };
                    successAction(restResponse);
                }
            }, errorAction)
                                         , null);
        }
Пример #2
0
        protected virtual void ProcessResponse(
            MvxRestRequest restRequest,
            HttpWebRequest httpRequest,
            Action<MvxStreamRestResponse> successAction,
            Action<Exception> errorAction)
        {
            httpRequest.BeginGetResponse(result =>
                                         TryCatch(() =>
                                             {
                                                 var response = (HttpWebResponse) httpRequest.EndGetResponse(result);

                                                 var code = response.StatusCode;

                                                 using (var responseStream = response.GetResponseStream())
                                                 {
                                                     var restResponse = new MvxStreamRestResponse
                                                         {
                                                             CookieCollection = response.Cookies,
                                                             Stream = responseStream,
                                                             Tag = restRequest.Tag,
                                                             StatusCode = code
                                                         };
                                                     successAction(restResponse);
                                                 }
                                             }, errorAction)
                                         , null);
        }