示例#1
0
        protected BaseClient(PingdomClientConfiguration configuration)
        {
            _baseClient = new HttpClient()
            {
                BaseAddress = new Uri(configuration.BaseAddress)
            };

            _baseClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                                                                            Convert.ToBase64String(Encoding.ASCII.GetBytes($"{configuration.UserName}:{configuration.Password}")));

            _baseClient.DefaultRequestHeaders.Add("app-key", configuration.AppKey);
            if (!string.IsNullOrEmpty(configuration.AccountEmail))
            {
                _baseClient.DefaultRequestHeaders.Add("Account-Email", configuration.AccountEmail);
            }
        }
        protected BaseClient(PingdomClientConfiguration configuration)
        {
            var credentials = new CredentialCache
            {
                {
                    new Uri(configuration.BaseAddress), "basic", new NetworkCredential(configuration.UserName, configuration.Password)
                }
            };

            var requestHandler = new WebRequestHandler {
                Credentials = credentials
            };

            _baseClient = new HttpClient(requestHandler)
            {
                BaseAddress = new Uri(configuration.BaseAddress)
            };

            _baseClient.DefaultRequestHeaders.Add("app-key", configuration.AppKey);
            if (!string.IsNullOrEmpty(configuration.AccountEmail))
            {
                _baseClient.DefaultRequestHeaders.Add("Account-Email", configuration.AccountEmail);
            }
        }
示例#3
0
 private Client(PingdomClientConfiguration configuration)
     : base(configuration)
 { }
示例#4
0
 public static Client CreateNew(PingdomClientConfiguration configuration)
 {
     return new Client(configuration);
 }
示例#5
0
 public static Client CreateNew(PingdomClientConfiguration configuration)
 {
     return(new Client(configuration));
 }
示例#6
0
 private Client(PingdomClientConfiguration configuration)
     : base(configuration)
 {
 }