Esempio n. 1
0
 public IHttpClient Create(string name, string baseUrl)
 {
     var key = BuildKey(name);
     if (_clients.ContainsKey(key))
     {
         throw new AlreadyExistsException($"A client with name '{name}' already exists");
     }
     var result = new NamedHttpClient(_logger, name, new HttpClient(), baseUrl);
     _clients.TryAdd(key, result);
     return result;
 }
Esempio n. 2
0
 public IHttpClient CreateOrUpdate(string name, string baseUrl)
 {
     var key = BuildKey(name);
     if (_clients.TryGetValue(key, out IHttpClient result))
     {
         result.SetBaseUrl(baseUrl);
         return result;
     }
     result = new NamedHttpClient(_logger, name, new HttpClient(), baseUrl);
     _clients.TryAdd(key, result);
     return result;
 }