From c5c6ac4a727bf95a151b5864cc3268f47738d97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Wed, 4 Jan 2023 15:24:09 +0100 Subject: [PATCH] Strip SysConfiguration to fit with the standard model --- .../Configuration/SysConfiguration.cs | 51 +++---------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/src/Connected.Host/Configuration/SysConfiguration.cs b/src/Connected.Host/Configuration/SysConfiguration.cs index d9de44a..561d847 100644 --- a/src/Connected.Host/Configuration/SysConfiguration.cs +++ b/src/Connected.Host/Configuration/SysConfiguration.cs @@ -1,49 +1,14 @@ -namespace Connected.Host.Configuration -{ - internal static class SysConfiguration - { - private const string DefaultStart = "Connected.Instance.Start, Connected.Instance"; - - private static List _microServices; - private static List _locations; - private static string _start; - public static List MicroServices => _microServices; - public static List Locations => _locations; - public static string Start => _start; - public static void Build() - { - var cb = new ConfigurationBuilder(); - var appPath = AppContext.BaseDirectory; - var segments = new Uri(appPath).Segments; - - segments = segments.Select(e => e.Replace("%20", " ")).ToArray(); - - for (var i = 1; i <= segments.Length; i++) - { - var pathBase = Path.Combine(segments[0..i]); - var filePath = Path.Combine(pathBase, "sys.json"); +namespace Connected.Host.Configuration; - if (File.Exists(filePath)) - { - cb.AddJsonFile(filePath, true, false); - break; - } - } - - cb.AddEnvironmentVariables(); - - var config = cb.Build(); +internal class SysConfiguration +{ + private const string DefaultStart = "Connected.Instance.Start, Connected.Instance"; - _microServices = new List(); - _locations = new List(); + private string _start = DefaultStart; - config.Bind("microServices", _microServices); - config.Bind("locations", _locations); + public List MicroServices { get; set; } = new(); - _start = config["start"]; + public List Repositories { get; set; } = new(); - if (string.IsNullOrWhiteSpace(_start)) - _start = DefaultStart; - } - } + public string Start { get => _start ?? DefaultStart; set => _start = value; } }