Beispiel #1
0
 /// <summary>ctor</summary>
 /// <param name="innerHandler">the next handler.</param>
 /// <param name="httpClientRecycler">the recycler to to be notified if while Dispose.</param>
 public DisposeRecycleHandler(
     HttpMessageHandler innerHandler,
     HttpClientRecycler httpClientRecycler
     ) : base(innerHandler)
 {
     this._HttpClientRecycler = httpClientRecycler;
 }
 /// <summary>ctor</summary>
 /// <param name="httpClientRecycler">owner</param>
 /// <param name="innerHandler">the next inner handler.</param>
 // <param name="configuration">the configuration to use</param>
 /// <param name="scope">the scope.</param>
 /// <param name="logger">the logger.</param>
 public ReuseRecycleHandler(
     HttpClientRecycler httpClientRecycler,
     HttpMessageHandler innerHandler,
     //HttpClientConfiguration configuration,
     IServiceScope scope,
     ILogger logger
     ) : base(innerHandler)
 {
     this._HttpClientRecycler = httpClientRecycler;
     //this._Configuration = configuration;
     this._Scope  = scope;
     this._Logger = logger;
 }
Beispiel #3
0
 /// <summary>Creates a HttpClient based on the configuration.</summary>
 /// <param name="configuration"></param>
 /// <returns>A HttpClient based on the configuration</returns>
 /// <remarks>The HttpClient will be created for each call of this - the underlying HttpClientHandler can be reused/shared.</remarks>
 public virtual HttpClient CreateHttpClient(HttpClientConfiguration configuration)
 {
     while (true)
     {
         if (this._Recyclers.TryGetValue(configuration, out var recycler))
         {
             if (recycler.IsValid())
             {
                 return(recycler.CreateHttpClient());
             }
         }
         {
             recycler = new HttpClientRecycler(this.Services, this.ScopeFactory, this.LoggerFactory, configuration);
             if (!this._Recyclers.TryAdd(configuration, recycler))
             {
                 continue;
             }
             else
             {
                 return(recycler.CreateHttpClient());
             }
         }
     }
 }
Beispiel #4
0
 public UsageLock(HttpClientRecycler owner)
 {
     this._Owner = owner;
 }