Exemplo n.º 1
0
        public void OnSendComplete(Dictionary <string, string> headers, byte[] bytes, string errorText)
        {
            sendingRoutine = null;
            Response       = null;
            Error          = null;

            if (string.IsNullOrEmpty(errorText))
            {
                try
                {
                    var response = api.ResponseDeserializer.Deserialize <ResponseT>(bytes);
                    Response = new WebApiResponse <ResponseT>(headers, response);
                }
                catch (SerializationException)
                {
                    Error = new WebApiError <ErrorT>(headers, null, bytes, "Failed to deserialize a response");
                }
            }
            else
            {
                try
                {
                    var error = api.ResponseDeserializer.Deserialize <ErrorT>(bytes);
                    Error = new WebApiError <ErrorT>(headers, error, bytes, errorText);
                }
                catch (SerializationException)
                {
                    Error = new WebApiError <ErrorT>(headers, null, bytes, errorText);
                }
            }

            if (Error == null)
            {
                api.OnRequestSuccess(this, Response);
            }
            else
            {
                api.OnRequestError(this, Error);
            }
        }
Exemplo n.º 2
0
 public abstract void OnRequestError(IWebApiRequest request, WebApiError <ErrorT> error);