Compare commits
2 Commits
91c7035162
...
fea7b6af42
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fea7b6af42 | ||
![]() |
1a34c7b4c4 |
@ -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<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>();
|
||||
|
||||
foreach (var assembly in Assemblies.All)
|
||||
@ -32,16 +37,16 @@ namespace Connected.Instance
|
||||
foreach (var startup in startups)
|
||||
{
|
||||
if (startup.CreateInstance<IStartup>() is IStartup start)
|
||||
await start.Initialize(args);
|
||||
await start.Initialize(config);
|
||||
}
|
||||
|
||||
foreach (var startup in startups)
|
||||
{
|
||||
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 Host.RunAsync();
|
||||
|
@ -1,10 +1,12 @@
|
||||
namespace Connected.Instance
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Connected.Instance
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Connected;
|
||||
@ -7,6 +8,6 @@ public interface IStartup
|
||||
{
|
||||
void ConfigureServices(IServiceCollection services);
|
||||
void Configure(WebApplication app);
|
||||
Task Initialize(Dictionary<string, string> args);
|
||||
Task Start(Dictionary<string, string> args);
|
||||
Task Initialize(IConfiguration config);
|
||||
Task Start(IConfiguration config);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Connected;
|
||||
@ -27,22 +28,22 @@ public abstract class Startup : IStartup
|
||||
|
||||
}
|
||||
|
||||
public async Task Initialize(Dictionary<string, string> args)
|
||||
public async Task Initialize(IConfiguration config)
|
||||
{
|
||||
await OnInitialize(args);
|
||||
await OnInitialize(config);
|
||||
}
|
||||
|
||||
protected virtual async Task OnInitialize(Dictionary<string, string> args)
|
||||
protected virtual async Task OnInitialize(IConfiguration config)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Start(Dictionary<string, string> args)
|
||||
public async Task Start(IConfiguration config)
|
||||
{
|
||||
await OnStart(args);
|
||||
await OnStart(config);
|
||||
}
|
||||
|
||||
protected virtual async Task OnStart(Dictionary<string, string> args)
|
||||
protected virtual async Task OnStart(IConfiguration config)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user