From 90cc4e7ca6ae4523fbc734e869cf8880505490be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Wed, 4 Jan 2023 15:14:15 +0100 Subject: [PATCH] Convert dictionary initialization to standard initialization --- src/Connected.Instance/Instance.cs | 15 ++++++++++----- src/Connected.Instance/Start.cs | 8 +++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Connected.Instance/Instance.cs b/src/Connected.Instance/Instance.cs index 8373921..f900cf5 100644 --- a/src/Connected.Instance/Instance.cs +++ b/src/Connected.Instance/Instance.cs @@ -1,5 +1,6 @@ using Connected.Interop; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; namespace Connected.Instance { @@ -7,9 +8,13 @@ namespace Connected.Instance { internal static WebApplication Host { get; private set; } - internal static async Task StartAsync(Dictionary args) + internal static async Task StartAsync(IConfiguration config) { - var builder = WebApplication.CreateBuilder(UnpackArguments(args)); + var options = new WebApplicationOptions(); + config.Bind(options); + + var builder = WebApplication.CreateBuilder(options); + var startups = Assemblies.QueryImplementations(); foreach (var assembly in Assemblies.All) @@ -32,16 +37,16 @@ namespace Connected.Instance foreach (var startup in startups) { if (startup.CreateInstance() is IStartup start) - await start.Initialize(args); + await start.Initialize(config); } foreach (var startup in startups) { if (startup.CreateInstance() is IStartup start) - await start.Start(args); + await start.Start(config); } - if (args.TryGetValue("entitySynchronization", out string? entities)) + if (config.GetValue("entitySynchronization") is string entities) await EntitySynchronizer.Synchronize(Host.Services, entities); await Host.RunAsync(); diff --git a/src/Connected.Instance/Start.cs b/src/Connected.Instance/Start.cs index 4aebec4..ab3d0ba 100644 --- a/src/Connected.Instance/Start.cs +++ b/src/Connected.Instance/Start.cs @@ -1,10 +1,12 @@ -namespace Connected.Instance +using Microsoft.Extensions.Configuration; + +namespace Connected.Instance { public static class Start { - public static async Task ConfigureAsync(Dictionary args) + public static async Task ConfigureAsync(IConfiguration config) { - await Instance.StartAsync(args); + await Instance.StartAsync(config); } } } \ No newline at end of file