Пример #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;
     }
 }
Пример #2
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveGFlags()
        {
            var request = new PlaceByCoordinates(-12.9516, 159.1547);

            request.GFlags.Add(GFlag.QuickMode);
            request.GFlags.ShouldContain(GFlag.QuickMode);
        }
        public void Yahoo_PlaceFinder_PlaceByCoordinates_Location_ShouldConvertLatitudeAndLongitudeToStringRepresentation()
        {
            var it = new PlaceByCoordinates(55.555, 111.111);

            it.ShouldNotBeNull();
            it.Location.ShouldEqual("55.555 111.111");
        }
Пример #4
0
 private Response ChannelFindByCoordinates(PlaceByCoordinates request, int retry = 0)
 {
     try
     {
         return(Channel.FindByCoordinates(request.Location, request.Locale,
                                          request.Start, request.Count, request.Offset,
                                          request.GetFlagsAsString(), request.GetGFlagsAsString(),
                                          request.AppId));
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(ChannelFindByCoordinates(request, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(ChannelFindByCoordinates(request, ++retry));
         }
         throw;
     }
 }
Пример #5
0
        public void Yahoo_PlaceFinder_PlaceByCoordinates_Location_ShouldConvertLatitudeAndLongitudeToStringRepresentation()
        {
            var it = new PlaceByCoordinates(55.555, 111.111);

            it.ShouldNotBeNull();
            it.Location.ShouldEqual("55.555 111.111");
        }
        public void Yahoo_PlaceFinder_PlaceByCoordinates_ShouldConstructWithLatitudeAndLongitude()
        {
            var it = new PlaceByCoordinates(55.555, 111.111);

            it.ShouldNotBeNull();
            it.Latitude.ShouldEqual(55.555);
            it.Longitude.ShouldEqual(111.111);
        }
Пример #7
0
        public ResultSet Find(PlaceByCoordinates request, string consumerKey, string consumerSecret)
        {
            if (request == null) throw new ArgumentNullException("request");
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);
            return response.PlaceFinder;
        }
Пример #8
0
        public void Yahoo_PlaceFinder_PlaceByCoordinates_ShouldConstructWithLatitudeAndLongitude()
        {
            var it = new PlaceByCoordinates(55.555, 111.111);

            it.ShouldNotBeNull();
            it.Latitude.ShouldEqual(55.555);
            it.Longitude.ShouldEqual(111.111);
        }
        public void Yahoo_PlaceFinder_PlaceByCoordinates_ShouldAllowLongitudeToBeChanged_AfterConstruction()
        {
            var it = new PlaceByCoordinates(55.555, 111.111) { Longitude = 88.888 };

            it.ShouldNotBeNull();
            it.Latitude.ShouldEqual(55.555);
            it.Longitude.ShouldEqual(88.888);
        }
Пример #10
0
        public void Yahoo_PlaceFinder_PlaceByCoordinates_ShouldAllowLongitudeToBeChanged_AfterConstruction()
        {
            var it = new PlaceByCoordinates(55.555, 111.111)
            {
                Longitude = 88.888
            };

            it.ShouldNotBeNull();
            it.Latitude.ShouldEqual(55.555);
            it.Longitude.ShouldEqual(88.888);
        }
Пример #11
0
        public ResultSet Find(PlaceByCoordinates request, string consumerKey, string consumerSecret)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);

            return(response.PlaceFinder);
        }
Пример #12
0
        public ResultSet Find(PlaceByCoordinates request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = ChannelFindByCoordinates(request);

            return(response.ResultSet);
        }
Пример #13
0
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByCoordinates_ShouldReturn1Result_ForYahooExample()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByCoordinates(37.775391, 122.412209);

                var resultSet = client.Find(request, ConsumerKey, ConsumerSecret);
                resultSet.ShouldNotBeNull();
                resultSet.Results.ShouldNotBeNull();
                resultSet.Count.ShouldEqual(1);
            }
        }
Пример #14
0
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByCoordinates_ShouldReturn1Result_ForYahooExample()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByCoordinates(37.775391, 122.412209);

                var resultSet = client.Find(request);
                resultSet.ShouldNotBeNull();
                resultSet.Results.ShouldNotBeNull();
                resultSet.Results.Count.ShouldEqual(1);
            }
        }
Пример #15
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;
     }
 }
Пример #16
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveGFlags()
 {
     var request = new PlaceByCoordinates(-12.9516, 159.1547);
     request.GFlags.Add(GFlag.QuickMode);
     request.GFlags.ShouldContain(GFlag.QuickMode);
 }
Пример #17
0
 internal static Uri GetUri(this PlaceByCoordinates request)
 {
     return(GetQLocationUri(request, request.Location));
 }