]> git.deb.at Git - rhonda/impostor.git/commitdiff
Make configs actually work with dependency injection
authorjs6pak <kubastaron@hotmail.com>
Wed, 24 Mar 2021 19:05:26 +0000 (20:05 +0100)
committerjs6pak <kubastaron@hotmail.com>
Wed, 24 Mar 2021 19:05:26 +0000 (20:05 +0100)
src/Impostor.Server/Config/AnnouncementsServerConfig.cs
src/Impostor.Server/Config/DebugConfig.cs
src/Impostor.Server/Config/ServerRedirectorConfig.cs
src/Impostor.Server/Config/ServerRedirectorNode.cs

index 3ea3eb33a57170ca6cd76e1248d06956420d4f3f..43f8f8ff80a5b28165f13e46bbfb037dfe6c779f 100644 (file)
@@ -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()
         {
index ef37d3972da908a29cb981f3933a9efac32563a6..72529de35289f098327f18e0db1133f922fbc08e 100644 (file)
@@ -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;
     }
 }
index 63285ad77271648fc8c920b15d38c8038631a91b..686ad7fdb01777fb2d455a0f1f2b3042a9a00dff 100644 (file)
@@ -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<ServerRedirectorNode>? 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<ServerRedirectorNode>? Nodes { get; }
+        public List<ServerRedirectorNode>? 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; }
         }
     }
 }
index c5752bf6b08aa5123af042dce9e531f0dd7fa8d3..c479512348655fb4402f8e821fe4d41478ed85c1 100644 (file)
@@ -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; }
     }
 }