2 implementations of Services
Microsoft.AspNetCore.Hosting (1)
Internal\WebHost.cs (1)
77public IServiceProvider Services
Microsoft.AspNetCore.Hosting.Tests (1)
Fakes\GenericWebHost.cs (1)
22public IServiceProvider Services => _host.Services;
102 references to Services
IStartupInjectionAssemblyName (1)
Program.cs (1)
15var applicationName = webHost.Services.GetRequiredService<IHostEnvironment>().ApplicationName;
Microsoft.AspNetCore.FunctionalTests (1)
WebHostFunctionalTests.cs (1)
124var factory = (ILoggerFactory)webHost.Services.GetService(typeof(ILoggerFactory));
Microsoft.AspNetCore.Hosting (4)
WebHostExtensions.cs (4)
92var shutdownMessage = host.Services.GetRequiredService<WebHostOptions>().SuppressStatusMessages ? string.Empty : "Application is shutting down..."; 114var hostingEnvironment = host.Services.GetService<IHostEnvironment>(); 115var options = host.Services.GetRequiredService<WebHostOptions>(); 154var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
Microsoft.AspNetCore.Hosting.Tests (77)
WebHostBuilderTests.cs (43)
33var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 164var services = host.Services.GetServices<IHostApplicationLifetime>(); 208Assert.NotNull(host.Services.GetService<ILoggerFactory>()); 369Assert.NotNull(host.Services.GetService<IConfiguration>()); 410var config = host.Services.GetService<IConfiguration>(); 481Assert.NotNull(host.Services.GetRequiredService<ServiceA>()); 482Assert.NotNull(host.Services.GetRequiredService<ServiceB>()); 498var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 524var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 550var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 585var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 611Assert.Equal(expected, host.Services.GetService<IHostEnvironment>().EnvironmentName); 612Assert.Equal(expected, host.Services.GetService<IWebHostEnvironment>().EnvironmentName); 614Assert.Equal(expected, host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().EnvironmentName); 615Assert.Equal(expected, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().EnvironmentName); 659Assert.Equal("/", host.Services.GetService<IHostEnvironment>().ContentRootPath); 660Assert.Equal("/", host.Services.GetService<IWebHostEnvironment>().ContentRootPath); 662Assert.Equal("/", host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath); 663Assert.Equal("/", host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath); 678var basePath = host.Services.GetRequiredService<IHostEnvironment>().ContentRootPath; 680var basePath2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath; 701Assert.Equal(appBase, host.Services.GetService<IHostEnvironment>().ContentRootPath); 703Assert.Equal(appBase, host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath); 732var hostingEnv = host.Services.GetService<IHostEnvironment>(); 734var hostingEnv2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>(); 750var hostingEnv = host.Services.GetService<IHostEnvironment>(); 752var hostingEnv2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>(); 768var hostingEnv = host.Services.GetService<IHostEnvironment>(); 781var hostingEnv = host.Services.GetService<IHostEnvironment>(); 797var hostingEnv = host.Services.GetService<IHostEnvironment>(); 813var hostingEnv = host.Services.GetService<IHostEnvironment>(); 827var hostingEnv = host.Services.GetService<IHostEnvironment>(); 879var factoryFromHost = host.Services.GetService<ILoggerFactory>(); 955var startup = host.Services.GetRequiredService<StartupVerifyServiceA>(); 1076var sink = host.Services.GetRequiredService<ITestSink>(); 1092var configuration = host.Services.GetRequiredService<IConfiguration>(); 1128var configuration = host.Services.GetRequiredService<IConfiguration>(); 1229var sink = host.Services.GetRequiredService<ITestSink>(); 1281var options = CreateWebHostOptions(host.Services.GetRequiredService<IConfiguration>()); 1301var filter = (MyStartupFilter)host.Services.GetServices<IStartupFilter>().FirstOrDefault(s => s is MyStartupFilter); 1337var appConfig = host.Services.GetRequiredService<IConfiguration>(); 1378var service = host.Services.GetServices<IHostedService>().OfType<NonThrowingHostedService>().First(); 1408var ordering = host.Services.GetRequiredService<StartOrder>();
WebHostTests.cs (34)
144var server = (FakeServer)host.Services.GetRequiredService<IServer>(); 163var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 165var lifetime2 = host.Services.GetRequiredService<AspNetCore.Hosting.IApplicationLifetime>(); 167var server = (FakeServer)host.Services.GetRequiredService<IServer>(); 315var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 384var singleton = (FakeService)host.Services.GetService<IFakeSingletonService>(); 385var transient = (FakeService)host.Services.GetService<IFakeService>(); 409var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>(); 411var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>(); 430var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>(); 432var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>(); 508var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 531var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 535var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>(); 555var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 558var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>(); 598var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 651var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 680var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>(); 682var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>(); 714var env = host.Services.GetService<IHostEnvironment>(); 716var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>(); 742Assert.NotNull(host.Services.GetRequiredService<IOptions<object>>()); 801var env = host.Services.GetService<IHostEnvironment>(); 803var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>(); 824var env = host.Services.GetService<IHostEnvironment>(); 826var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>(); 847var env = host.Services.GetService<IWebHostEnvironment>(); 852var env1 = host.Services.GetService<IHostingEnvironment>(); 865var env = host.Services.GetRequiredService<IHostEnvironment>(); 909var server = (FakeServer)host.Services.GetRequiredService<IServer>(); 930var services = host.Services; 931var services2 = host.Services; 1075var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>();
Microsoft.AspNetCore.Hosting.WindowsServices (1)
WebHostService.cs (1)
48.Services
Microsoft.AspNetCore.Hosting.WindowsServices.Tests (2)
WebHostServiceTests.cs (2)
24var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>(); 38var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Infrastructure\ServerFactory.cs (1)
69EnsureDatabaseCreated(result.Host.Services);
Microsoft.AspNetCore.Mvc.Testing (1)
WebApplicationFactory.cs (1)
91return _host?.Services ?? _server.Host.Services;
Microsoft.AspNetCore.Server.Kestrel.Tests (6)
HttpsConfigurationTests.cs (2)
208Assert.True(host.Services.GetRequiredService<IHttpsConfigurationService>().IsInitialized); 235Assert.False(host.Services.GetRequiredService<IHttpsConfigurationService>().IsInitialized);
WebHostBuilderKestrelExtensionsTests.cs (4)
62var transportFactories = hostBuilder.Build().Services.GetServices<IConnectionListenerFactory>(); 85var factories = hostBuilder.Build().Services.GetServices<IConnectionListenerFactory>(); 93var factoriesReversed = hostBuilderReversed.Build().Services.GetServices<IConnectionListenerFactory>(); 110Assert.IsType<KestrelServerImpl>(hostBuilder.Build().Services.GetService<IServer>());
Microsoft.AspNetCore.TestHost (2)
TestServer.cs (1)
101Services = host.Services;
WebHostBuilderExtensions.cs (1)
56return (TestServer)host.Services.GetRequiredService<IServer>();
Microsoft.AspNetCore.TestHost.Tests (1)
TestServerTests.cs (1)
188Assert.Equal(testService, server.Host.Services.GetRequiredService<TestService>());
Microsoft.AspNetCore.Tests (5)
WebHostTests.cs (5)
38var config = host.Services.GetRequiredService<IConfiguration>(); 39var monitor = host.Services.GetRequiredService<IOptionsMonitor<HostFilteringOptions>>(); 93var linkGenerator = host.Services.GetService(typeof(LinkGenerator)); 105var logger = host.Services.GetRequiredService<ILogger<WebHostTests>>(); 121var routeOptions = host.Services.GetService<IOptions<RouteOptions>>();