tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
WebHostBuilderExtensions.cs
Go to the documentation of this file.
1using System;
2using System.IO.Abstractions;
3
4using Microsoft.AspNetCore.Builder;
5using Microsoft.AspNetCore.Hosting;
6using Microsoft.Extensions.DependencyInjection;
7using Microsoft.Extensions.Logging;
8using Microsoft.Extensions.Options;
9
16
18{
23 {
33 public static IWebHostBuilder UseApplication(
34 this IWebHostBuilder builder,
35 IAssemblyInformationProvider assemblyInformationProvider,
36 IIOManager ioManager,
37 IPostSetupServices postSetupServices,
38 IFileSystem fileSystem)
39 {
40 ArgumentNullException.ThrowIfNull(builder);
41 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
42 ArgumentNullException.ThrowIfNull(ioManager);
43 ArgumentNullException.ThrowIfNull(postSetupServices);
44 ArgumentNullException.ThrowIfNull(fileSystem);
45
46 return builder.ConfigureServices(
47 (context, services) =>
48 {
49 var application = new Application(context.Configuration, context.HostingEnvironment);
50 application.ConfigureServices(services, assemblyInformationProvider, ioManager, postSetupServices, fileSystem);
51 services.AddSingleton(application);
52 })
53 .Configure(ConfigureApplication);
54 }
55
60 static void ConfigureApplication(IApplicationBuilder applicationBuilder)
61 => applicationBuilder
62 .ApplicationServices
63 .GetRequiredService<Application>()
64 .Configure(
65 applicationBuilder, // TODO: find a way to call this func and auto-resolve the services
66 applicationBuilder.ApplicationServices.GetRequiredService<IServerControl>(),
67 applicationBuilder.ApplicationServices.GetRequiredService<ITokenFactory>(),
68 applicationBuilder.ApplicationServices.GetRequiredService<IServerPortProvider>(),
69 applicationBuilder.ApplicationServices.GetRequiredService<IAssemblyInformationProvider>(),
70 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<ControlPanelConfiguration>>(),
71 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<GeneralConfiguration>>(),
72 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<DatabaseConfiguration>>(),
73 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<SecurityConfiguration>>(),
74 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<SwarmConfiguration>>(),
75 applicationBuilder.ApplicationServices.GetRequiredService<IOptions<InternalConfiguration>>(),
76 applicationBuilder.ApplicationServices.GetRequiredService<ILogger<Application>>());
77 }
78}
Extension methods for the IWebHostBuilder class.
static IWebHostBuilder UseApplication(this IWebHostBuilder builder, IAssemblyInformationProvider assemblyInformationProvider, IIOManager ioManager, IPostSetupServices postSetupServices, IFileSystem fileSystem)
Workaround for using the Application class for server startup.
static void ConfigureApplication(IApplicationBuilder applicationBuilder)
Configures a given applicationBuilder .
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:14
Set of objects needed to configure an Core.Application.