Exemplo n.º 1
0
        /// <summary>
        /// Geocodes the given address and returns the result.
        /// </summary>
        /// <param name="coderName"></param>
        /// <param name="country"></param>
        /// <param name="postalCode"></param>
        /// <param name="commune"></param>
        /// <param name="street"></param>
        /// <param name="houseNumber"></param>
        /// <returns></returns>
        public static IGeoCoderResult Code(
            string coderName,
            string country,
            string postalCode,
            string commune,
            string street,
            string houseNumber)
        {
            IGeoCoder coderInstance = null;

            // create and cache the coder class.
            if (_coders == null)
            {
                _coders = new Dictionary <string, IGeoCoder>();
            }
            if (!_coders.TryGetValue(coderName, out coderInstance))
            {
                throw new InvalidOperationException(string.Format(
                                                        "No geocoder registered with name: {0}", coderName));
            }

            return(coderInstance.Code(
                       country,
                       postalCode,
                       commune,
                       street,
                       houseNumber));
        }