示例#1
0
 private static BossResponse OAuthFind(PlaceByCoordinates request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json          = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject <BossContainer>(json);
             if (bossContainer != null)
             {
                 return(bossContainer.BossResponse);
             }
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
 }
 private static BossResponse OAuthFind(PlaceByCoordinates request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject<BossContainer>(json);
             if (bossContainer != null) return bossContainer.BossResponse;
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
 }