Пример #1
0
        public string Execute(ITRestRequest request)
        {
            IRestResponse restResponse = this._client.Execute(request.Request);
            string        empty        = string.Empty;

            empty = (restResponse.StatusCode < HttpStatusCode.BadRequest ? restResponse.Content : string.Format("{{ \"RestException\" : {0} }}", restResponse.Content));
            return(empty);
        }
Пример #2
0
 public virtual void ExecuteAsync <T>(ITRestRequest request, Action <T> callback)
     where T : new()
 {
     request.Request.OnBeforeDeserialization = (IRestResponse resp) => {
         if (resp.StatusCode >= HttpStatusCode.BadRequest)
         {
             string str = string.Format("{{ \"RestException\" : {0} }}", resp.Content);
             resp.Content  = null;
             resp.RawBytes = Encoding.UTF8.GetBytes(str.ToString());
         }
     };
     request.DateFormat = "ddd, dd MMM yyyy HH:mm:ss '+0000'";
     this._client.ExecuteAsync <T>(request.Request, (IRestResponse <T> response) => callback(response.Data));
 }
Пример #3
0
 public virtual T Execute <T>(ITRestRequest request)
     where T : new()
 {
     request.Request.OnBeforeDeserialization = (IRestResponse resp) => {
         if (resp.StatusCode >= HttpStatusCode.BadRequest)
         {
             string str = string.Format("{{ \"RestException\" : {0} }}", resp.Content);
             resp.Content  = null;
             resp.RawBytes = Encoding.UTF8.GetBytes(str.ToString());
         }
     };
     request.DateFormat = this.DateFormat;
     return(this._client.Execute <T>(request.Request).Data);
 }
Пример #4
0
 public ITRestRequest AddSignHeader(ITRestRequest request, string name, string value)
 {
     return(request.AddParameter(name, value, TParameterType.HttpHeader));
 }