-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionServiceCollectionExtensions.cs
More file actions
31 lines (25 loc) · 1.33 KB
/
Copy pathConnectionServiceCollectionExtensions.cs
File metadata and controls
31 lines (25 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Extensions.DependencyInjection;
using RustPlusBot.Discord;
using RustPlusBot.Features.Connections.Hosting;
using RustPlusBot.Features.Connections.Listening;
using RustPlusBot.Features.Connections.Removal;
using RustPlusBot.Features.Connections.Supervisor;
namespace RustPlusBot.Features.Connections;
/// <summary>DI registration for the live-connection feature.</summary>
public static class ConnectionServiceCollectionExtensions
{
/// <summary>Registers the socket source, supervisor, module seam, and hosted service.</summary>
/// <param name="services">The service collection to add to.</param>
/// <returns>The same service collection, for chaining.</returns>
public static IServiceCollection AddConnections(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.AddSingleton<IRustSocketSource, RustPlusSocketSource>();
services.AddSingleton<IConnectionSupervisor, ConnectionSupervisor>();
services.AddScoped<IServerRemovalService, ServerRemovalService>();
// Contribute this assembly's interaction modules to the Discord layer.
services.AddSingleton(new InteractionModuleAssembly(typeof(ConnectionServiceCollectionExtensions).Assembly));
services.AddHostedService<ConnectionHostedService>();
return services;
}
}