Convert dictionary initialization to standard initialization
This commit is contained in:
		
							parent
							
								
									1a34c7b4c4
								
							
						
					
					
						commit
						fea7b6af42
					
				@ -1,5 +1,6 @@
 | 
				
			|||||||
using Connected.Interop;
 | 
					using Connected.Interop;
 | 
				
			||||||
using Microsoft.AspNetCore.Builder;
 | 
					using Microsoft.AspNetCore.Builder;
 | 
				
			||||||
 | 
					using Microsoft.Extensions.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Connected.Instance
 | 
					namespace Connected.Instance
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -7,9 +8,13 @@ namespace Connected.Instance
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		internal static WebApplication Host { get; private set; }
 | 
							internal static WebApplication Host { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		internal static async Task StartAsync(Dictionary<string, string> 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<IStartup>();
 | 
								var startups = Assemblies.QueryImplementations<IStartup>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			foreach (var assembly in Assemblies.All)
 | 
								foreach (var assembly in Assemblies.All)
 | 
				
			||||||
@ -32,16 +37,16 @@ namespace Connected.Instance
 | 
				
			|||||||
			foreach (var startup in startups)
 | 
								foreach (var startup in startups)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (startup.CreateInstance<IStartup>() is IStartup start)
 | 
									if (startup.CreateInstance<IStartup>() is IStartup start)
 | 
				
			||||||
					await start.Initialize(args);
 | 
										await start.Initialize(config);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			foreach (var startup in startups)
 | 
								foreach (var startup in startups)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (startup.CreateInstance<IStartup>() is IStartup start)
 | 
									if (startup.CreateInstance<IStartup>() is IStartup start)
 | 
				
			||||||
					await start.Start(args);
 | 
										await start.Start(config);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (args.TryGetValue("entitySynchronization", out string? entities))
 | 
								if (config.GetValue<string?>("entitySynchronization") is string entities)
 | 
				
			||||||
				await EntitySynchronizer.Synchronize(Host.Services, entities);
 | 
									await EntitySynchronizer.Synchronize(Host.Services, entities);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			await Host.RunAsync();
 | 
								await Host.RunAsync();
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,12 @@
 | 
				
			|||||||
namespace Connected.Instance
 | 
					using Microsoft.Extensions.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Connected.Instance
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	public static class Start
 | 
						public static class Start
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		public static async Task ConfigureAsync(Dictionary<string, string> args)
 | 
							public static async Task ConfigureAsync(IConfiguration config)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			await Instance.StartAsync(args);
 | 
								await Instance.StartAsync(config);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user