예제 #1
0
        private void ConfigureContractKey(string contractKey, IConfigReader configReader)
        {
            BaseUris.Add(contractKey, new Uri(configReader.GetAndEnsureString("BaseUrl", onlyFromSubSection: true)));

            var authentication = configReader.GetString("Authentication");

            if (!string.IsNullOrEmpty(authentication))
            {
                if (authentication.ToLower() == "oauth2")
                {
                    Authenticators.Add(contractKey, new Oauth2AuthorizationConfiguration(configReader));
                }
                else
                {
                    throw new RestClientConfigurationException($"Authentication method '{authentication}' is not supported.");
                }
            }

            var timeout = configReader.GetTimeSpan("Timeout");

            if (timeout.HasValue)
            {
                Timeouts[contractKey] = timeout.Value;
            }
        }