private async Task <AsyncResult <Tuple <CivicAddress, GeoCoordinate> > > TryLookupInternal(IPAddress ip) { var downloader = new Downloader { EnableCompression = true }; downloader.Headers["Accept"] = "application/json"; downloader.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0"; FreeGeoIPResponse result = await downloader.DownloadAsync <FreeGeoIPResponse>(BuildUrl(ip)).ConfigureAwait(false); bool success; CivicAddress address; GeoCoordinate coordinates; if (result == null) { address = null; coordinates = null; success = false; } else { address = result.ToCivicAddress(); coordinates = result.ToGeoCoordinates(); success = true; } return(new AsyncResult <Tuple <CivicAddress, GeoCoordinate> >(success, new Tuple <CivicAddress, GeoCoordinate>(address, coordinates))); }
private bool TryLookupInternal(IPAddress ip, out CivicAddress address, out GeoCoordinate coordinates) { var downloader = new Downloader { EnableCompression = true }; downloader.Headers["Accept"] = "application/json"; downloader.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0"; FreeGeoIPResponse result = downloader.Download <FreeGeoIPResponse>(BuildUrl(ip)); if (result == null) { address = null; coordinates = null; return(false); } address = result.ToCivicAddress(); coordinates = result.ToGeoCoordinates(); return(true); }