More options conversions

This commit is contained in:
Jordan Dominion
2025-08-16 00:47:16 -04:00
parent 870ba54471
commit dfac1d7736
2 changed files with 17 additions and 17 deletions
@@ -30,22 +30,22 @@ namespace Tgstation.Server.Host.Core
/// </summary>
readonly IInstanceManager instanceManager;
/// <summary>
/// The <see cref="IOptions{TOptions}"/> of <see cref="InternalConfiguration"/> for the <see cref="CommandPipeManager"/>.
/// </summary>
readonly IOptions<InternalConfiguration> internalConfigurationOptions;
/// <summary>
/// The <see cref="ILogger"/> for the <see cref="CommandPipeManager"/>.
/// </summary>
readonly ILogger<CommandPipeManager> logger;
/// <summary>
/// The <see cref="InternalConfiguration"/> for the <see cref="CommandPipeManager"/>.
/// </summary>
readonly InternalConfiguration internalConfiguration;
/// <summary>
/// Initializes a new instance of the <see cref="CommandPipeManager"/> class.
/// </summary>
/// <param name="serverControl">The value of <see cref="serverControl"/>.</param>
/// <param name="instanceManager">The value of <see cref="instanceManager"/>.</param>
/// <param name="internalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="internalConfiguration"/>.</param>
/// <param name="internalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="internalConfigurationOptions"/>.</param>
/// <param name="logger">The value of <see cref="logger"/>.</param>
public CommandPipeManager(
IServerControl serverControl,
@@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Core
{
this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
this.instanceManager = instanceManager ?? throw new ArgumentNullException(nameof(instanceManager));
internalConfiguration = internalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(internalConfigurationOptions));
this.internalConfigurationOptions = internalConfigurationOptions ?? throw new ArgumentNullException(nameof(internalConfigurationOptions));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -65,7 +65,7 @@ namespace Tgstation.Server.Host.Core
logger.LogTrace("Starting...");
// grab both pipes asap so we can close them on error
var commandPipe = internalConfiguration.CommandPipe;
var commandPipe = internalConfigurationOptions.Value.CommandPipe;
var supportsPipeCommands = !String.IsNullOrWhiteSpace(commandPipe);
await using var commandPipeClient = supportsPipeCommands
? new AnonymousPipeClientStream(
@@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.Core
if (!supportsPipeCommands)
logger.LogDebug("No command pipe name specified in configuration");
var readyPipe = internalConfiguration.ReadyPipe;
var readyPipe = internalConfigurationOptions.Value.ReadyPipe;
var supportsReadyNotification = !String.IsNullOrWhiteSpace(readyPipe);
if (supportsReadyNotification)
{
@@ -13,28 +13,28 @@ namespace Tgstation.Server.Host.Core
sealed class ServerPortProivder : IServerPortProvider
{
/// <inheritdoc />
public ushort HttpApiPort => generalConfiguration.ApiPort;
public ushort HttpApiPort => generalConfigurationOptions.Value.ApiPort;
/// <summary>
/// The <see cref="GeneralConfiguration"/> for the <see cref="ServerPortProivder"/>.
/// The <see cref="IOptions{TOptions}"/> of <see cref="GeneralConfiguration"/> for the <see cref="ServerPortProivder"/>.
/// </summary>
readonly GeneralConfiguration generalConfiguration;
readonly IOptions<GeneralConfiguration> generalConfigurationOptions;
/// <summary>
/// Initializes a new instance of the <see cref="ServerPortProivder"/> class.
/// </summary>
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
/// <param name="configuration">The <see cref="IConfiguration"/> to use.</param>
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfigurationOptions"/>.</param>
/// <param name="logger">The <see cref="ILogger"/> to use.</param>
public ServerPortProivder(
IOptions<GeneralConfiguration> generalConfigurationOptions,
IConfiguration configuration,
IOptions<GeneralConfiguration> generalConfigurationOptions,
ILogger<ServerPortProivder> logger)
{
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
ArgumentNullException.ThrowIfNull(configuration);
this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
var usingDefaultPort = generalConfiguration.ApiPort == default;
var usingDefaultPort = generalConfigurationOptions.Value.ApiPort == default;
if (!usingDefaultPort)
return;
@@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Core
if (!UInt16.TryParse(portString, out var result))
throw new InvalidOperationException($"Failed to parse HTTP EndPoint port: {httpEndpoint}");
generalConfiguration.ApiPort = result;
this.generalConfigurationOptions.Value.ApiPort = result;
}
}
}