Amazon.Extensions.NETCore.Setup.ClientFactory.CreateConfig C# (CSharp) Метод

CreateConfig() приватный статический Метод

Creates the ClientConfig object for the service client.
private static CreateConfig ( Type serviceInterfaceType, AWSOptions options ) : ClientConfig
serviceInterfaceType System.Type
options AWSOptions
Результат Amazon.Runtime.ClientConfig
        private static ClientConfig CreateConfig(Type serviceInterfaceType, AWSOptions options)
        {
            var configTypeName = serviceInterfaceType.Namespace + "." + serviceInterfaceType.Name.Substring(1) + "Config";
            var configType = serviceInterfaceType.GetTypeInfo().Assembly.GetType(configTypeName);

            var constructor = configType.GetConstructor(EMPTY_TYPES);
            ClientConfig config = constructor.Invoke(EMPTY_PARAMETERS) as ClientConfig;

            var defaultConfig = options.DefaultClientConfig;
            if (options.IsDefaultClientConfigSet)
            {
                var emptyArray = new object[0];
                var singleArray = new object[1];

                var clientConfigTypeInfo = typeof(ClientConfig).GetTypeInfo();
                foreach (var property in clientConfigTypeInfo.DeclaredProperties)
                {
                    if (property.GetMethod != null && property.SetMethod != null)
                    {
                        // Skip RegionEndpoint because it is set below and calling the get method on the
                        // property triggers the default region fallback mechanism.
                        if (string.Equals(property.Name, "RegionEndpoint", StringComparison.Ordinal))
                            continue;

                        singleArray[0] = property.GetMethod.Invoke(defaultConfig, emptyArray);
                        if (singleArray[0] != null)
                        {
                            property.SetMethod.Invoke(config, singleArray);
                        }
                    }
                }
            }

            // Setting RegionEndpoint only if ServiceURL was not set, because ServiceURL value will be lost otherwise
            if (options.Region != null && string.IsNullOrEmpty(defaultConfig.ServiceURL))
            {
                config.RegionEndpoint = options.Region;
            }

            return config;
        }
    }