Beispiel #1
0
        public LoggingOverheadBenchmark()
        {
            Handler        = new FakeClientHandler();
            LoggerProvider = new FakeLoggerProvider();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(b => b.AddProvider(LoggerProvider));
            serviceCollection.AddHttpClient("example", c =>
            {
                c.BaseAddress = new Uri("http://example.com/");
                c.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            })
            .ConfigurePrimaryHttpMessageHandler(() => Handler);

            var services = serviceCollection.BuildServiceProvider();

            Factory = services.GetRequiredService <IHttpClientFactory>();
        }
Beispiel #2
0
 public Logger(FakeLoggerProvider provider)
 {
     _provider = provider;
 }