Пример #1
0
        /// <summary>
        /// Gets the endpoint for a service in a region.
        /// </summary>
        /// <param name="serviceName">The services system name.</param>
        /// <exception cref="System.ArgumentException">Thrown when the request service does not have a valid endpoint in the region.</exception>
        /// <returns></returns>
        public Endpoint GetEndpointForService(string serviceName)
        {
            if (!RegionEndpoint.loaded)
            {
                RegionEndpoint.LoadEndpointDefinitionFromEmbeddedResource();
            }

            Endpoint endpoint = null;

            if (!this.endpoints.TryGetValue(serviceName, out endpoint))
            {
                // If the endpoint is not found check to see if downloading the latest definitions from the web
                // contains a definition for the endpoint.
                if (!RegionEndpoint.loadedFromWeb)
                {
                    LoadEndpointDefinitionFromWeb();
                    return(GetEndpointForService(serviceName));
                }

                throw new ArgumentException(string.Format("No endpoint found for service {0} for region {1}.", serviceName, this.DisplayName), "serviceName");
            }

            return(endpoint);
        }
Пример #2
0
        /// <summary>
        /// Gets the region based on its system name like "us-west-1"
        /// </summary>
        /// <param name="systemName">The system name of the service like "us-west-1"</param>
        /// <returns></returns>
        public static RegionEndpoint GetBySystemName(string systemName)
        {
            if (!RegionEndpoint.loaded)
            {
                RegionEndpoint.LoadEndpointDefinitionFromEmbeddedResource();
            }

            RegionEndpoint region = null;

            if (!hashBySystemName.TryGetValue(systemName.ToLower(), out region))
            {
                // If the region is not found check to see if downloading the latest definitions from the web
                // contains a definition for the region.
                if (!RegionEndpoint.loadedFromWeb)
                {
                    LoadEndpointDefinitionFromWeb();
                    return(GetBySystemName(systemName));
                }

                throw new ArgumentException(string.Format("No region found for name {0}.", systemName), "systemName");
            }

            return(region);
        }