tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
WebHostBuilderExtensions.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.AspNetCore.Builder;
4using Microsoft.AspNetCore.Hosting;
5using Microsoft.Extensions.DependencyInjection;
6using Microsoft.Extensions.Logging;
7using Microsoft.Extensions.Options;
8
15
17{
22 {
31 public static IWebHostBuilder UseApplication(
32 this IWebHostBuilder builder,
33 IAssemblyInformationProvider assemblyInformationProvider,
34 IIOManager ioManager,
35 IPostSetupServices postSetupServices)
36 {
37 ArgumentNullException.ThrowIfNull(builder);
38 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
39 ArgumentNullException.ThrowIfNull(ioManager);
40 ArgumentNullException.ThrowIfNull(postSetupServices);
41
42 return builder.ConfigureServices(
43 (context, services) =>
44 {
45 var application = new Application(context.Configuration, context.HostingEnvironment);
46 application.ConfigureServices(services, assemblyInformationProvider, ioManager, postSetupServices);
47 services.AddSingleton(application);
48 })
49 .Configure(ConfigureApplication);
50 }
51
56 static void ConfigureApplication(IApplicationBuilder applicationBuilder)
57 => applicationBuilder
58 .ApplicationServices
59 .GetRequiredService<Application>()
60 .Configure(
61 applicationBuilder, // TODO: find a way to call this func and auto-resolve the services
62 applicationBuilder.ApplicationServices.GetRequiredService<IServerControl>(),
63 applicationBuilder.ApplicationServices.GetRequiredService<ITokenFactory>(),
64 applicationBuilder.ApplicationServices.GetRequiredService<IServerPortProvider>(),
65 applicationBuilder.ApplicationServices.GetRequiredService<IAssemblyInformationProvider>(),
66 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<ControlPanelConfiguration>>(),
67 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<GeneralConfiguration>>(),
68 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<SwarmConfiguration>>(),
69 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<InternalConfiguration>>(),
70 applicationBuilder.ApplicationServices.GetRequiredService<ILogger<Application>>());
71 }
72}
Sets up dependency injection.
Extension methods for the IWebHostBuilder class.
static void ConfigureApplication(IApplicationBuilder applicationBuilder)
Configures a given applicationBuilder .
static IWebHostBuilder UseApplication(this IWebHostBuilder builder, IAssemblyInformationProvider assemblyInformationProvider, IIOManager ioManager, IPostSetupServices postSetupServices)
Workaround for using the Application class for server startup.
Represents a service that may take an updated Host assembly and run it, stopping the current assembly...
Provides access to the server's HttpApiPort.
Interface for using filesystems.
Definition IIOManager.cs:13
Set of objects needed to configure an Core.Application.