public ISerializer GetSerializer(ApiFormat format)
        {
            switch (format)
            {
            case ApiFormat.JSON:
                return(jsonSerializer);

            default:
            case ApiFormat.XML:
                return(xmlSerializer);
            }
        }
        public string GetContentType(ApiFormat apiFormat)
        {
            switch (ApiFormat)
            {
            case Primitive.ApiFormat.JSON:
                return("application/json");

            default:
            case Primitive.ApiFormat.XML:
                return("application/xml");
            }
        }
Exemplo n.º 3
0
    public CampfireUrlBuilder(ISite campfireSite, ApiFormat format)
    {
      this.CampfireSite = campfireSite;

      switch (format)
      {
        case ApiFormat.Xml:
          Format = "xml";
          break;
        default:
          Format = "json";
          break;
      }
    }
Exemplo n.º 4
0
 public override System.Exception CreateApiException(ApiFormat format, string content, IResponse response)
 {
     try
     {
         var errors = GetSerializer(format).Deserialize <V2.Payload.Feed.Errors>(content);
         return(ApiException.Factory(errors, response));
     }
     catch (Exception firstAttemptEx)
     {
         try
         {
             var errors = GetSerializer(format).Deserialize <V2.Payload.Feed.ErrorsWithoutNS>(content);
             return(ApiException.Factory(errors, response));
         }
         catch (Exception secondAttempEx)
         {
             var exceptionList = new Exception[] { firstAttemptEx, secondAttempEx };
             var aggrEx        = new AggregateException("Unable to parse error response >" + content + "<", exceptionList);
             throw aggrEx;
         }
     }
 }
Exemplo n.º 5
0
 public void AddPayload(string payload, ApiFormat apiFormat)
 {
     HttpRequest.Content = new StringContent((string)payload, Encoding.UTF8, Config.GetContentType(ApiFormat));
 }
Exemplo n.º 6
0
 public abstract System.Exception CreateApiException(ApiFormat format, string content,
                                                     Base.Http.IResponse response);
Exemplo n.º 7
0
 public ISerializer GetSerializer(ApiFormat format)
 {
     return(serializerFactory.GetSerializer(format));
 }
 public ApiProxy(ApiFormat format)
 {
     _resourceRequester = new ResourceRequester(format, "http://localhost");
     _representation = ResourceRequester.PerformRequest("/api");
 }