title: Add Custom TypedClient with Refit
body: <p>I am having issue when adding a custom client with Refit. I dont want default httpClient. The reason to do is that I dont want my consumers to change httpclient configuration when they are consuming my refit implemented Client. Separation of concerns I guess.</p>
  
  <p>I have a class CustomHttpClient which is inherited from httpClient.</p>
  
  <pre><code>var client = new CustomHttpClient();
              serviceCollection.AddRefitClient&lt;IMyAPi&gt;().AddTypedClient(sp =&gt; client).ConfigureHttpClient((serviceProvider, httpClient) =&gt;
              {
                  var options = serviceProvider.GetRequiredService&lt;IOptions&lt;CustomClientOptions&gt;&gt;().Value;
                  httpClient.BaseAddress =
                      new Uri(
                          $"{options.ApiProtocol}://{options.ApiHost}/{options.ApiVersion}");
              }).AddHttpMessageHandler&lt;CustomHttpClientHandler&gt;();
  </code></pre>
  
  <p>CustomHttpClient.cs</p>
  
  <pre><code> public class CustomHttpClient : HttpClient
      {
          public CustomHttpClient(HttpMessageHandler handler) : base(handler)
          {
          }
  
          public CustomHttpClient()
          {
          }
      }
  </code></pre>
  
  <p>I am getting exception:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: 'ValueFactory attempted to access
    the Value property of this instance.'</p>
  </blockquote>
  
  <p>AddTypedClient adds the client as Transient but I want it as Singleton. I am not sure how to tell Refit to use my CustomHttpClient &amp; CustomHttpClientHandler which should be singleton?</p>
  
  <p><strong>Update:</strong>
  I tried below code and its giving new exception.</p>
  
  <pre><code>serviceCollection.AddSingleton&lt;CustomHttpClient&gt;();
  serviceCollection.AddSingleton&lt;CustomHttpClientHandler&gt;();
  serviceCollection.AddHttpClient&lt;CustomHttpClient&gt;(c =&gt; c.BaseAddress = new Uri("http://dummy.com"));
  serviceCollection.AddRefitClient&lt;IMyAPi&gt;().AddHttpMessageHandler&lt;CustomHttpClientHandler&gt;();
  </code></pre>
  
  <blockquote>
    <p>System.InvalidOperationException: 'A suitable constructor for type
    'BBC.Studios.Rightsline.Client.RightslineHttpClient' could not be
    located. Ensure the type is concrete and services are registered for
    all parameters of a public constructor.'</p>
  </blockquote>