private static RegionEndpoint GetEndpoint(string systemName, string displayName) { RegionEndpoint regionEndpoint = null; if (displayName == null) { lock (_hashBySystemName) { if (_hashBySystemName.TryGetValue(systemName, out regionEndpoint)) { return(regionEndpoint); } } // GetRegionEndpoint will always return a non-null value. If the the region(systemName) is unknown, // the providers will create a fallback instance that will generate an endpoint to the best // of its knowledge. displayName = RegionEndpointProvider.GetRegionEndpoint(systemName).DisplayName; } lock (_hashBySystemName) { if (_hashBySystemName.TryGetValue(systemName, out regionEndpoint)) { return(regionEndpoint); } regionEndpoint = new RegionEndpoint(systemName, displayName); _hashBySystemName.Add(regionEndpoint.SystemName, regionEndpoint); } return(regionEndpoint); }
public static RegionEndpoint GetBySystemName(string systemName) { RegionEndpoint value = null; if (_hashBySystemName.TryGetValue(systemName, out value)) { return(value); } IRegionEndpoint regionEndpoint = RegionEndpointProvider.GetRegionEndpoint(systemName); return(NewEndpoint(systemName, regionEndpoint.DisplayName)); }
/// <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) { RegionEndpoint region = null; if (_hashBySystemName.TryGetValue(systemName, out region)) { return(region); } IRegionEndpoint regionEndpointFromProvider = RegionEndpointProvider.GetRegionEndpoint(systemName); // We received an instance of IRegionEndpoint from a provider, // now we should wrap it in RegionEndpoint before returning the data back to the client code. // GetRegionEndpoint will always return a non-null value. If the the region(systemName) is unknown, // the providers will create a fallback instance that will generate an endpoint to the best // of its knowledge. return(NewEndpoint(systemName, regionEndpointFromProvider.DisplayName)); }
/// <summary> /// Returns the DNS suffix for the given partition, or /// an empty string if a matching partition was not found in endpoints.json /// </summary> /// <param name="partition">partition</param> /// <returns>DNS suffix for the given partition, empty string if a matching partition was not found</returns> public static string GetDnsSuffixForPartition(string partition) { return(RegionEndpointProvider.GetDnsSuffixForPartition(partition)); }