コード例 #1
0
        private void CreateEndpointAndAddToServiceMap(JsonData result, string regionName, string serviceName, bool dualStack)
        {
            string text = ((string)result["hostname"]).Replace("{service}", serviceName).Replace("{region}", regionName).Replace("{dnsSuffix}", (string)_partitionJsonData["dnsSuffix"]);

            if (dualStack)
            {
                if (serviceName.Equals("s3", StringComparison.OrdinalIgnoreCase))
                {
                    if (text.Equals("s3.amazonaws.com", StringComparison.OrdinalIgnoreCase))
                    {
                        text = "s3.dualstack.us-east-1.amazonaws.com";
                    }
                    else if (!text.StartsWith("s3-external-", StringComparison.OrdinalIgnoreCase))
                    {
                        if (text.StartsWith("s3-", StringComparison.OrdinalIgnoreCase))
                        {
                            text = "s3." + text.Substring(3);
                        }
                        if (text.StartsWith("s3.", StringComparison.OrdinalIgnoreCase))
                        {
                            text = text.Replace("s3.", "s3.dualstack.");
                        }
                    }
                }
                else
                {
                    text = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", serviceName, "dualstack." + regionName, (string)_partitionJsonData["dnsSuffix"]);
                }
            }
            string   authregion = null;
            string   text2      = null;
            JsonData jsonData   = result["credentialScope"];

            if (jsonData != null)
            {
                authregion = DetermineAuthRegion(jsonData);
                if (jsonData["service"] != null && string.Compare((string)jsonData["service"], serviceName, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    text2 = (string)jsonData["service"];
                }
            }
            string signatureVersionOverride = DetermineSignatureOverride(result, serviceName);

            RegionEndpoint.Endpoint endpoint = new RegionEndpoint.Endpoint(text, authregion, signatureVersionOverride);
            _serviceMap.Add(serviceName, dualStack, endpoint);
            if (!string.IsNullOrEmpty(text2) && !_serviceMap.ContainsKey(text2))
            {
                _serviceMap.Add(text2, dualStack, endpoint);
            }
        }