tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ProviderFactory.cs
Go to the documentation of this file.
1using System;
2using System.Globalization;
3
4using Microsoft.Extensions.Logging;
5using Microsoft.Extensions.Options;
6
12
14{
17 {
22
27
32
36 readonly ILoggerFactory loggerFactory;
37
42
47
61 ILoggerFactory loggerFactory,
62 IOptions<GeneralConfiguration> generalConfigurationOptions,
63 IOptions<FileLoggingConfiguration> loggingConfigurationOptions)
64 {
65 this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
66 this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
67 this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
68 this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
69 generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
70 loggingConfiguration = loggingConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(loggingConfigurationOptions));
71 }
72
74 public IProvider CreateProvider(Models.ChatBot settings)
75 {
76 ArgumentNullException.ThrowIfNull(settings);
77 return settings.Provider switch
78 {
79 ChatProvider.Irc => new IrcProvider(
82 loggerFactory.CreateLogger<IrcProvider>(),
84 settings,
86 ChatProvider.Discord => new DiscordProvider(
89 loggerFactory.CreateLogger<DiscordProvider>(),
91 settings,
93 _ => throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid ChatProvider: {0}", settings.Provider)),
94 };
95 }
96 }
97}
readonly FileLoggingConfiguration loggingConfiguration
The FileLoggingConfiguration for the ProviderFactory.
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the ProviderFactory.
IProvider CreateProvider(Models.ChatBot settings)
Create a IProvider.A new IProvider.
readonly GeneralConfiguration generalConfiguration
The GeneralConfiguration for the ProviderFactory.
readonly ILoggerFactory loggerFactory
The ILoggerFactory for the ProviderFactory.
readonly IJobManager jobManager
The IJobManager for the ProviderFactory.
ProviderFactory(IJobManager jobManager, IAssemblyInformationProvider assemblyInformationProvider, IAsyncDelayer asyncDelayer, ILoggerFactory loggerFactory, IOptions< GeneralConfiguration > generalConfigurationOptions, IOptions< FileLoggingConfiguration > loggingConfigurationOptions)
Initializes a new instance of the ProviderFactory class.
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the ProviderFactory.
Manages the runtime of Jobs.