private static string GetMessage(string errorMessage, GoogleStatus status)
 {
     return(string.Format("Status = '{0}'. {1}",
                          status,
                          string.IsNullOrEmpty(errorMessage)
             ? "There was an error processing the geocoding request."
             : errorMessage));
 }
예제 #2
0
        private IEnumerable <GoogleAddress> ProcessWebResponse(WebResponse response)
        {
            XPathDocument  xmlDoc = LoadXmlResponse(response);
            XPathNavigator nav    = xmlDoc.CreateNavigator();

            GoogleStatus status = EvaluateStatus((string)nav.Evaluate("string(/GeocodeResponse/status)"));

            if (status != GoogleStatus.Ok && status != GoogleStatus.ZeroResults)
            {
                throw new GoogleGeocodingException(status);
            }

            if (status == GoogleStatus.Ok)
            {
                return(ParseAddresses(nav.Select("/GeocodeResponse/result")).ToArray());
            }

            return(new GoogleAddress[0]);
        }
 public GoogleGeocodingException(Exception innerException)
     : base(DefaultMessage, innerException)
 {
     this.Status = GoogleStatus.Error;
 }
 public GoogleGeocodingException(GoogleStatus status)
     : base(DefaultMessage)
 {
     this.Status = status;
 }
		public GoogleGeoCodingException(Exception innerException)
			: base(defaultMessage, innerException)
		{
			this.Status = GoogleStatus.Error;
		}
		public GoogleGeoCodingException(GoogleStatus status)
			: base(defaultMessage)
		{
			this.Status = status;
		}
 public GoogleGeocodingException(GoogleStatus status, string errorMessage, Exception innerException)
     : base(GetMessage(errorMessage, status), innerException)
 {
     Status = status;
 }
 public GoogleGeocodingException(GoogleStatus status, Exception innerException)
     : base(GetMessage(null, status), innerException)
 {
     Status = status;
 }
 public GoogleGeocodingException(GoogleStatus status) : base(GetMessage(null, status))
 {
     Status = status;
 }