private static void SearchResponse(IpAddressGeocoder geoCoder, Response response) { IpAddressLocation ipAddressLocation = null; Exception ex = response.GetException(); if (ex != null || response.GetCode() != HttpStatusCode.OK) { if (geoCoder._listener != null) { geoCoder._listener.Done(geoCoder._searchAddress, null); } return; } try { Result result = response.GetResult(); ipAddressLocation = new IpAddressLocation { ipaddress = result.GetAsString("ipaddress"), country = result.GetAsString("country"), region = result.GetAsString("region"), city = result.GetAsString("city"), postal = result.GetAsString("postal"), latitude = result.GetAsString("latitude"), longitude = result.GetAsString("longitude"), metro_code = result.GetAsString("metro_code"), area_code = result.GetAsString("area_code"), isp = result.GetAsString("isp"), organization = result.GetAsString("organization"), error = result.GetAsString("error") }; } catch (Exception) { } if (geoCoder._listener != null) { geoCoder._listener.Done(geoCoder._searchAddress, ipAddressLocation); } }
private static void SearchResponse(IpAddressGeocoder geoCoder, Response response) { IpAddressLocation ipAddressLocation = null; Exception ex = response.GetException(); if (ex != null || response.GetCode() != HttpStatusCode.OK) { if (geoCoder._listener != null) { geoCoder._listener.Done(geoCoder._searchAddress, null); } return; } try { Result result = response.GetResult(); ipAddressLocation = new IpAddressLocation { ipaddress = result.GetAsString("ipaddress"), country = result.GetAsString("country"), region = result.GetAsString("region"), city = result.GetAsString("city"), postal = result.GetAsString("postal"), latitude = result.GetAsString("latitude"), longitude = result.GetAsString("longitude"), metro_code = result.GetAsString("metro_code"), area_code = result.GetAsString("area_code"), isp = result.GetAsString("isp"), organization = result.GetAsString("organization"), error = result.GetAsString("error") }; } catch (Exception) { } if (geoCoder._listener != null) { geoCoder._listener.Done(geoCoder._searchAddress, ipAddressLocation); } }
public void Done(Object context, Response response) { IpAddressGeocoder geoCoder = (IpAddressGeocoder)context; SearchResponse(geoCoder, response); }
public void ReadProgress(Object context, int bytes, int total) { IpAddressGeocoder geoCoder = (IpAddressGeocoder)context; geoCoder._listener.ReadProgress(bytes, total); }