title: .NET Core AddHttpClient Dynamic Configuration
body: <p>I'm using <code>AddHttpClient</code> extension to configure <code>HttpClient</code> used in my personal <code>RestClient</code>.</p>
  
  <pre><code>    public class RestClient : IRestClient
      {
          public RestClient(IRestClientSettings settings, HttpClient httpClient)
          {
              ...
          }
      }
  
      public class RestClientFactory
      {
          public IRestClient Create(IRestClientSettings settings)
          {
              // how to create IRestClient with above configuration??
          }
      }
  
      public static IServiceCollection AddServices(this IServiceCollection services)
      {
          services.AddHttpClient&lt;IRestClient, RestClient&gt;((provider, client) =&gt;
          {
              // problem, this is always same binded instance, 
              // not the one provided in RestClientFactory
              var settings = provider.GetService&lt;IRestClientSettings&gt;(); 
              settings.ConfigureHttp(provider, client);
          });
      }
  </code></pre>
  
  <p>Everything is fine if I inject <code>IRestClient</code> in my services but the problem is when I want to dynamically create <code>IRestClient</code> using <code>RestClientFactory</code> to use custom configuration (not one provided by default DI binding for IRestClientSettings). How can I achieve that?</p>
  
  <p>IRestClientSettings are just custom settings along with ConfigureHttp method where user can define custom HttpClient settings.</p>