Пример #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);
            }
        }
Пример #2
0
        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)
 {
 }