In the beta 8 of ASP.NET 5, I had access to the CallContextServiceLocator. This is no longer available in the RC1.
How can I replace the call to CallContextServiceLocator in the following code below. I am using that code to create test instance of the service.
private static TestServer CreateTestServer(HttpMessageHandler backchannelHttpHandler = null)
{
HostingEnvironment hostingEnvironment = new HostingEnvironment { EnvironmentName = "Testing", };
Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv =
CallContextServiceLocator.Locator.ServiceProvider.GetRequiredService<Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment>();
Startup serviceStartup = new Startup(hostingEnvironment, appEnv, backchannelHttpHandler);
Action<IApplicationBuilder> configureApp = app => serviceStartup.Configure(app, appEnv, new LoggerFactory());
Action<IServiceCollection> configureServices = svc => serviceStartup.ConfigureServices(svc);
WebApplicationBuilder webAppBuilder = new WebApplicationBuilder();
webAppBuilder.Configure(configureApp);
webAppBuilder.ConfigureServices(configureServices);
return new TestServer(webAppBuilder);
}
There's no replacement per se, it's dead gone buried RIP :). You can use platform services to get specific components. Also the hosting API has been revamped to be less sucky so it doesn't require anything to be passed into it by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With