public IHttpClientBuilder Use <THandler>(params object[] args) where THandler : DelegatingHandler { HandlerDefs.Add(new HandlerDefinition { HandlerType = typeof(THandler), CtorArgs = args }); return(this); }
internal HttpMessageHandler Build() { var root = FinalHandlerDef != null ? (HttpMessageHandler)Activator.CreateInstance(FinalHandlerDef.HandlerType, FinalHandlerDef.CtorArgs) : new HttpClientHandler(); FinalHandlerConfigurators.Each(x => x(root)); return(HandlerDefs .Reverse() .Select(x => (DelegatingHandler)Activator.CreateInstance(x.HandlerType, x.CtorArgs)) .Aggregate(root, (current, next) => { next.InnerHandler = current; return next; })); }