From: js6pak Date: Wed, 24 Mar 2021 19:05:26 +0000 (+0100) Subject: Make configs actually work with dependency injection X-Git-Tag: v1.3.0~3^2 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=3321e3049f4ef6ef7e24c1c4ae6148cf428e8e9b;p=rhonda%2Fimpostor.git Make configs actually work with dependency injection --- diff --git a/src/Impostor.Server/Config/AnnouncementsServerConfig.cs b/src/Impostor.Server/Config/AnnouncementsServerConfig.cs index 3ea3eb3..43f8f8f 100644 --- a/src/Impostor.Server/Config/AnnouncementsServerConfig.cs +++ b/src/Impostor.Server/Config/AnnouncementsServerConfig.cs @@ -1,5 +1,4 @@ -using System.Text.Json.Serialization; -using Impostor.Server.Utils; +using Impostor.Server.Utils; namespace Impostor.Server.Config { @@ -9,19 +8,11 @@ namespace Impostor.Server.Config private string? _resolvedListenIp; - [JsonConstructor] - public AnnouncementsServerConfig(bool enabled = true, string listenIp = "0.0.0.0", ushort listenPort = 22024) - { - Enabled = enabled; - ListenIp = listenIp; - ListenPort = listenPort; - } - - public bool Enabled { get; } + public bool Enabled { get; set; } = true; - public string ListenIp { get; } + public string ListenIp { get; set; } = "0.0.0.0"; - public ushort ListenPort { get; } + public ushort ListenPort { get; set; } = 22024; public string ResolveListenIp() { diff --git a/src/Impostor.Server/Config/DebugConfig.cs b/src/Impostor.Server/Config/DebugConfig.cs index ef37d39..72529de 100644 --- a/src/Impostor.Server/Config/DebugConfig.cs +++ b/src/Impostor.Server/Config/DebugConfig.cs @@ -1,20 +1,11 @@ -using System.Text.Json.Serialization; - -namespace Impostor.Server.Config +namespace Impostor.Server.Config { public class DebugConfig { public const string Section = "Debug"; - [JsonConstructor] - public DebugConfig(bool gameRecorderEnabled = false, string? gameRecorderPath = null) - { - GameRecorderEnabled = gameRecorderEnabled; - GameRecorderPath = gameRecorderPath; - } - - public bool GameRecorderEnabled { get; } + public bool GameRecorderEnabled { get; set; } - public string? GameRecorderPath { get; } + public string GameRecorderPath { get; set; } = string.Empty; } } diff --git a/src/Impostor.Server/Config/ServerRedirectorConfig.cs b/src/Impostor.Server/Config/ServerRedirectorConfig.cs index 63285ad..686ad7f 100644 --- a/src/Impostor.Server/Config/ServerRedirectorConfig.cs +++ b/src/Impostor.Server/Config/ServerRedirectorConfig.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Text.Json.Serialization; +using System.Diagnostics.CodeAnalysis; namespace Impostor.Server.Config { @@ -7,35 +7,21 @@ namespace Impostor.Server.Config { public const string Section = "ServerRedirector"; - [JsonConstructor] - public ServerRedirectorConfig(bool enabled = false, bool master = false, NodeLocator? locator = null, List? nodes = null) - { - Enabled = enabled; - Master = master; - Locator = locator; - Nodes = nodes; - } + public bool Enabled { get; set; } - public bool Enabled { get; } + public bool Master { get; set; } - public bool Master { get; } + public NodeLocator? Locator { get; set; } - public NodeLocator? Locator { get; } - - public List? Nodes { get; } + public List? Nodes { get; set; } public class NodeLocator { - [JsonConstructor] - public NodeLocator(string redis, string udpMasterEndpoint) - { - Redis = redis; - UdpMasterEndpoint = udpMasterEndpoint; - } - - public string Redis { get; } + [AllowNull] + public string Redis { get; set; } - public string UdpMasterEndpoint { get; } + [AllowNull] + public string UdpMasterEndpoint { get; set; } } } } diff --git a/src/Impostor.Server/Config/ServerRedirectorNode.cs b/src/Impostor.Server/Config/ServerRedirectorNode.cs index c5752bf..c479512 100644 --- a/src/Impostor.Server/Config/ServerRedirectorNode.cs +++ b/src/Impostor.Server/Config/ServerRedirectorNode.cs @@ -1,18 +1,13 @@ -using System.Text.Json.Serialization; +using System.Diagnostics.CodeAnalysis; namespace Impostor.Server.Config { public class ServerRedirectorNode { - [JsonConstructor] - public ServerRedirectorNode(string ip, ushort port) - { - Ip = ip; - Port = port; - } + [AllowNull] + public string Ip { get; set; } - public string Ip { get; } - - public ushort Port { get; } + [AllowNull] + public ushort Port { get; set; } } }