Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the GeocodeException class.
        /// </summary>
        /// <param name="request">The request that caused the exception to be thrown.</param>
        /// <param name="response">The response that caused the exception to be thrown.</param>
        public GeocodeException(GeocodeRequest request, GeocodeResponse response)
            : this()
        {
            if (request != null)
            {
                this.address = request.Address;
                this.requestUri = request.RequestUri;
            }

            if (response != null)
            {
                this.responseName = response.Name;
                this.responseStatusCode = response.Status.Code;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the response of the geocode request asynchronously.
        /// </summary>
        /// <param name="callback">An action to call when the asynchronous operation has completed.</param>
        public void GetResponseAsync(Action<GeocodeResponse> callback)
        {
            if (this.response == null)
            {
                WebRequest request = WebRequest.Create(this.RequestUri);

                request.BeginGetResponse(
                    delegate(IAsyncResult async)
                    {
                        this.response = this.DeserializeResponse(request.EndGetResponse(async));
                        callback(this.response);
                    },
                    null);
            }
            else
            {
                callback(this.response);
            }
        }
Beispiel #3
0
        public GeocodeResponse GetResponse()
        {
            if (this.response == null)
            {
                WebRequest request = WebRequest.Create(this.RequestUri);
                this.response = this.DeserializeResponse(request.GetResponse());
            }

            return this.response;
        }