diff --git a/apps/NewBlazor/Components/Pages/Counter.razor b/apps/NewBlazor/Components/Pages/Counter.razor
index 624373ca2..471fbaa93 100644
--- a/apps/NewBlazor/Components/Pages/Counter.razor
+++ b/apps/NewBlazor/Components/Pages/Counter.razor
@@ -10,7 +10,7 @@
@code {
- private int currentCount = 0;
+ private int currentCount;
private void IncrementCount()
{
diff --git a/apps/NewBlazor/Components/Pages/Weather.razor b/apps/NewBlazor/Components/Pages/Weather.razor
index 6cdac744f..78d1c3361 100644
--- a/apps/NewBlazor/Components/Pages/Weather.razor
+++ b/apps/NewBlazor/Components/Pages/Weather.razor
@@ -1,5 +1,5 @@
@page "/weather"
-@attribute [StreamRendering(true)]
+@attribute [StreamRendering]
Weather
diff --git a/apps/NewBlazor/NewBlazor.csproj b/apps/NewBlazor/NewBlazor.csproj
index d19aa4c13..4d825d403 100644
--- a/apps/NewBlazor/NewBlazor.csproj
+++ b/apps/NewBlazor/NewBlazor.csproj
@@ -11,6 +11,7 @@
+
diff --git a/perf/Sitko.Core.App.Perf/Program.cs b/perf/Sitko.Core.App.Perf/Program.cs
index 61b99373b..561c28f0f 100644
--- a/perf/Sitko.Core.App.Perf/Program.cs
+++ b/perf/Sitko.Core.App.Perf/Program.cs
@@ -2,7 +2,9 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
+using Sitko.Core.App.Localization;
using Sitko.Core.App.Tests;
namespace Sitko.Core.App.Perf;
@@ -23,8 +25,9 @@ public class LocalizationTest
[GlobalSetup]
public void GlobalSetup()
{
- var application = new LocalizationTestApplication(Array.Empty());
- var host = application.GetHostBuilder().Build();
+ var builder = Host.CreateApplicationBuilder();
+ builder.AddJsonLocalization(options => options.AddDefaultResource());
+ var host = builder.Build();
factory = host.Services.GetService();
type = typeof(LocalizationTests);
}
@@ -53,4 +56,3 @@ public void GlobalSetup()
[Benchmark]
public string DefaultInvariantFallback() => Localizer["DefaultBaz"];
}
-
diff --git a/src/Sitko.Core.App.Web/IWebApplicationModule.cs b/src/Sitko.Core.App.Web/IWebApplicationModule.cs
index 9c7fd3dfa..2ee17730d 100644
--- a/src/Sitko.Core.App.Web/IWebApplicationModule.cs
+++ b/src/Sitko.Core.App.Web/IWebApplicationModule.cs
@@ -35,7 +35,7 @@ public interface IWebApplicationModule : IWebApplicationModule,
where TModuleOptions : class, new()
{
void ConfigureWebHost(IApplicationContext applicationContext, ConfigureWebHostBuilder webHostBuilder,
- TModuleOptions valueTuple)
+ TModuleOptions options)
{
}
}
diff --git a/src/Sitko.Core.App.Web/WebApplication.cs b/src/Sitko.Core.App.Web/WebApplication.cs
deleted file mode 100644
index 0ee212bb5..000000000
--- a/src/Sitko.Core.App.Web/WebApplication.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Routing;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
-namespace Sitko.Core.App.Web;
-
-// public abstract class WebApplication : HostedApplication
-// {
-// protected WebApplication(string[] args) : base(args)
-// {
-// }
-
-
-
- //
- // public virtual void BeforeRoutingHook(IApplicationContext applicationContext,
- // IApplicationBuilder appBuilder)
- // {
- // foreach (var webModule in GetWebModules(applicationContext))
- // {
- // webModule.ConfigureBeforeUseRouting(applicationContext, appBuilder);
- // }
- // }
- //
- // public virtual void AfterRoutingHook(IApplicationContext applicationContext,
- // IApplicationBuilder appBuilder)
- // {
- // foreach (var webModule in GetWebModules(applicationContext))
- // {
- // webModule.ConfigureAfterUseRouting(applicationContext, appBuilder);
- // }
- // }
- //
- // public virtual void AuthMiddlewareHook(IApplicationContext applicationContext,
- // IApplicationBuilder appBuilder)
- // {
- // foreach (var webModule in GetWebModules(applicationContext))
- // {
- // webModule.ConfigureAuthMiddleware(applicationContext, appBuilder);
- // }
- // }
- //
- // public virtual void EndpointsHook(IApplicationContext applicationContext,
- // IApplicationBuilder appBuilder, IEndpointRouteBuilder endpoints)
- // {
- // foreach (var webModule in GetWebModules(applicationContext))
- // {
- // webModule.ConfigureEndpoints(applicationContext, appBuilder, endpoints);
- // }
- // }
-//}
-
-// public abstract class WebApplication : WebApplication where TStartup : BaseStartup
-// {
-// protected WebApplication(string[] args) : base(args)
-// {
-// }
-//
-// // protected override void ConfigureAppConfiguration(HostBuilderContext context,
-// // IConfigurationBuilder configurationBuilder)
-// // {
-// // base.ConfigureAppConfiguration(context, configurationBuilder);
-// //
-// // configurationBuilder.AddEnvironmentVariables();
-// // }
-//
-// // protected override void ConfigureHostConfiguration(IConfigurationBuilder configurationBuilder)
-// // {
-// // base.ConfigureHostConfiguration(configurationBuilder);
-// // configurationBuilder.AddUserSecrets(true);
-// // configurationBuilder.AddEnvironmentVariables();
-// // }
-//
-// // protected override void ConfigureHostBuilder(IHostBuilder builder)
-// // {
-// // base.ConfigureHostBuilder(builder);
-// // builder
-// // .ConfigureServices(collection =>
-// // {
-// // collection.AddSingleton(typeof(WebApplication), this);
-// // collection.AddSingleton(typeof(WebApplication), this);
-// // });
-// // }
-//
-// // protected override void PostConfigureHostBuilder(IApplicationContext applicationContext, IHostBuilder hostBuilder)
-// // {
-// // base.PostConfigureHostBuilder(applicationContext, hostBuilder);
-// // hostBuilder.ConfigureWebHostDefaults(webBuilder =>
-// // {
-// // webBuilder.UseSetting("ApplicationId", Id.ToString());
-// // webBuilder.UseStartup();
-// // ConfigureWebHostDefaults(applicationContext, webBuilder);
-// // });
-// // }
-//
-// // protected virtual void ConfigureWebHostDefaults(IApplicationContext applicationContext,
-// // IWebHostBuilder webHostBuilder)
-// // {
-// // }
-//
-// // public WebApplication Run()
-// // {
-// // CreateAppHost().Start();
-// // return this;
-// // }
-// //
-// // public WebApplication Run(int port)
-// // {
-// // CreateAppHost(builder =>
-// // builder.ConfigureWebHostDefaults(
-// // webHostBuilder => webHostBuilder.UseUrls($"http://*:{port}"))).Start();
-// // return this;
-// // }
-// }
-
-// public static class WebApplicationExtensions
-// {
-// // public static TWebApplication Run(this TWebApplication application)
-// // where TWebApplication : WebApplication where TStartup : BaseStartup
-// // {
-// // application.Run();
-// // return application;
-// // }
-// //
-// // public static TWebApplication Run(this TWebApplication application, int port)
-// // where TStartup : BaseStartup
-// // where TWebApplication : WebApplication
-// // {
-// // application.Run(port);
-// // return application;
-// // }
-// }
diff --git a/src/Sitko.Core.App.Web/WebApplicationExtensions.cs b/src/Sitko.Core.App.Web/WebApplicationExtensions.cs
index 77490cc93..918f32d87 100644
--- a/src/Sitko.Core.App.Web/WebApplicationExtensions.cs
+++ b/src/Sitko.Core.App.Web/WebApplicationExtensions.cs
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Sitko.Core.App.Web;
@@ -22,7 +23,7 @@ protected override void ConfigureHostBuilder(Applicatio
if (module is TModule and IWebApplicationModule webModule &&
options is TModuleOptions webModuleOptions)
{
- webModule?.ConfigureWebHost(BootApplicationContext, webApplicationBuilder.WebHost, webModuleOptions);
+ webModule.ConfigureWebHost(BootApplicationContext, webApplicationBuilder.WebHost, webModuleOptions);
}
}
}
@@ -30,13 +31,12 @@ protected override void ConfigureHostBuilder(Applicatio
public static class WebApplicationExtensions
{
+ public static SitkoCoreApplicationBuilder AddSitkoCore(this WebApplicationBuilder builder) =>
+ builder.AddSitkoCore(Array.Empty());
+
public static SitkoCoreApplicationBuilder AddSitkoCore(this WebApplicationBuilder builder, string[] args)
{
- builder.Services.AddTransient();
- // if (builder.Builder is WebApplicationBuilder webApplicationBuilder)
- // {
- // webApplicationBuilder.WebHost.
- // }
+ builder.Services.TryAddTransient();
return new SitkoCoreWebApplicationBuilder(builder, args);
}
diff --git a/src/Sitko.Core.App/Application.cs b/src/Sitko.Core.App/Application.cs
index a19c21c89..c8dbb4a21 100644
--- a/src/Sitko.Core.App/Application.cs
+++ b/src/Sitko.Core.App/Application.cs
@@ -1,215 +1,215 @@
-using System.Text.Json;
-using JetBrains.Annotations;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-
-namespace Sitko.Core.App;
-
-public abstract class Application : IApplication
-{
- // private readonly List moduleRegistrations =
- // new();
-
- //private readonly Dictionary store = new();
- //private bool disposed;
-
- protected Application(string[] args)
- {
- //Args = args;
- //AddModule();
- }
-
-
- protected string[] Args { get; set; }
-
- public static string OptionsKey => nameof(Application);
-
- public Guid Id { get; } = Guid.NewGuid();
-
-
- // public string Name => GetApplicationOptions().Name;
- // public string Version => GetApplicationOptions().Version;
-
- // public async ValueTask DisposeAsync()
- // {
- // if (disposed)
- // {
- // return;
- // }
- //
- // await DisposeAsync(true);
- // GC.SuppressFinalize(this);
- // disposed = true;
- // }
-
- protected virtual ValueTask DisposeAsync(bool disposing) => new();
-
- [PublicAPI]
- //public ApplicationOptions GetApplicationOptions() => GetContext().Options;
-
-
-
- protected virtual void ConfigureHostConfiguration(IConfigurationBuilder configurationBuilder)
- {
- }
-
- protected virtual void ConfigureAppConfiguration(HostBuilderContext context,
- IConfigurationBuilder configurationBuilder)
- {
- }
-
-
- [PublicAPI]
- //public Dictionary GetModulesOptions() => GetModulesOptions(GetContext());
-
-
-
- public async Task RunAsync()
- {
- // LogInternal("Run app start");
- // LogInternal("Build and init");
- // var context = await BuildAppContextAsync();
-
- // var enabledModules = GetEnabledModuleRegistrations(context).ToArray();
- // foreach (var enabledModule in enabledModules)
- // {
- // var shouldContinue = await enabledModule.GetInstance().OnBeforeRunAsync(this, context, Args);
- // if (!shouldContinue)
- // {
- // return;
- // }
- // }
-
- // LogInternal("Check required modules");
- // var modulesCheckSuccess = true;
- // foreach (var registration in enabledModules)
- // {
- // var result =
- // registration.CheckRequiredModules(context,
- // enabledModules.Select(r => r.Type).ToArray());
- // if (!result.isSuccess)
- // {
- // foreach (var missingModule in result.missingModules)
- // {
- // LogInternal($"Required module {missingModule} for module {registration.Type} is not registered");
- // }
- //
- // modulesCheckSuccess = false;
- // }
- // }
-
- // if (!modulesCheckSuccess)
- // {
- // LogInternal("Check required modules failed");
- // return;
- // }
-
- // foreach (var enabledModule in enabledModules)
- // {
- // var shouldContinue = await enabledModule.GetInstance().OnAfterRunAsync(this, context, Args);
- // if (!shouldContinue)
- // {
- // return;
- // }
- // }
-
- //await DoRunAsync();
- }
-
- protected abstract Task DoRunAsync();
-
- protected abstract Task BuildAppContextAsync();
-
- public abstract Task StopAsync();
-
- // protected async Task InitAsync(IServiceProvider serviceProvider)
- // {
- // LogInternal("Build and init async start");
- // using var scope = serviceProvider.CreateScope();
- // var logger = scope.ServiceProvider.GetRequiredService>();
- // logger.LogInformation("Init modules");
- // // var registrations = GetEnabledModuleRegistrations(GetContext(scope.ServiceProvider));
- // // var context = GetContext(scope.ServiceProvider);
- // // foreach (var configurationModule in registrations.Select(module => module.GetInstance())
- // // .OfType())
- // // {
- // // configurationModule.CheckConfiguration(context, scope.ServiceProvider);
- // // }
- // //
- // // foreach (var registration in registrations)
- // // {
- // // logger.LogInformation("Init module {Module}", registration.Type);
- // // await registration.InitAsync(context, scope.ServiceProvider);
- // // }
- //
- // LogInternal("Build and init async done");
- // }
-
- protected virtual void LogInternal(string message) { }
-
- protected abstract bool CanAddModule();
-
- // [PublicAPI]
- // protected void RegisterModule(
- // Action? configureOptions = null,
- // string? optionsKey = null)
- // where TModule : IApplicationModule, new() where TModuleOptions : BaseModuleOptions, new()
- // {
- // if (!CanAddModule())
- // {
- // throw new InvalidOperationException("App host is already built. Can't add modules after it");
- // }
- //
- // var instance = new TModule();
- // if (!instance.AllowMultiple && HasModule())
- // {
- // throw new InvalidOperationException($"Module {typeof(TModule)} already registered");
- // }
- //
- // moduleRegistrations.Add(
- // new ApplicationModuleRegistration(instance, configureOptions, optionsKey));
- // }
-
- // protected virtual void InitApplication()
- // {
- // }
-
-
- // [PublicAPI]
- // protected abstract IApplicationContext GetContext();
- //
- // [PublicAPI]
- // protected abstract IApplicationContext GetContext(IServiceProvider serviceProvider);
-
-
-
-
- public Application AddModule() where TModule : BaseApplicationModule, new()
-
- {
- //RegisterModule();
- return this;
- }
-
- public Application AddModule(
- Action configureOptions,
- string? optionsKey = null)
- where TModule : IApplicationModule, new()
- where TModuleOptions : BaseModuleOptions, new()
- {
- //RegisterModule(configureOptions, optionsKey);
- return this;
- }
-
- public Application AddModule(
- Action? configureOptions = null,
- string? optionsKey = null)
- where TModule : IApplicationModule, new()
- where TModuleOptions : BaseModuleOptions, new() =>
- AddModule((_, moduleOptions) =>
- {
- configureOptions?.Invoke(moduleOptions);
- }, optionsKey);
-}
+// using System.Text.Json;
+// using JetBrains.Annotations;
+// using Microsoft.Extensions.Configuration;
+// using Microsoft.Extensions.DependencyInjection;
+// using Microsoft.Extensions.Hosting;
+// using Microsoft.Extensions.Logging;
+//
+// namespace Sitko.Core.App;
+//
+// public abstract class Application : IApplication
+// {
+// // private readonly List moduleRegistrations =
+// // new();
+//
+// //private readonly Dictionary store = new();
+// //private bool disposed;
+//
+// protected Application(string[] args)
+// {
+// //Args = args;
+// //AddModule();
+// }
+//
+//
+// protected string[] Args { get; set; }
+//
+// public static string OptionsKey => nameof(Application);
+//
+// public Guid Id { get; } = Guid.NewGuid();
+//
+//
+// // public string Name => GetApplicationOptions().Name;
+// // public string Version => GetApplicationOptions().Version;
+//
+// // public async ValueTask DisposeAsync()
+// // {
+// // if (disposed)
+// // {
+// // return;
+// // }
+// //
+// // await DisposeAsync(true);
+// // GC.SuppressFinalize(this);
+// // disposed = true;
+// // }
+//
+// protected virtual ValueTask DisposeAsync(bool disposing) => new();
+//
+// [PublicAPI]
+// //public ApplicationOptions GetApplicationOptions() => GetContext().Options;
+//
+//
+//
+// protected virtual void ConfigureHostConfiguration(IConfigurationBuilder configurationBuilder)
+// {
+// }
+//
+// protected virtual void ConfigureAppConfiguration(HostBuilderContext context,
+// IConfigurationBuilder configurationBuilder)
+// {
+// }
+//
+//
+// [PublicAPI]
+// //public Dictionary GetModulesOptions() => GetModulesOptions(GetContext());
+//
+//
+//
+// public async Task RunAsync()
+// {
+// // LogInternal("Run app start");
+// // LogInternal("Build and init");
+// // var context = await BuildAppContextAsync();
+//
+// // var enabledModules = GetEnabledModuleRegistrations(context).ToArray();
+// // foreach (var enabledModule in enabledModules)
+// // {
+// // var shouldContinue = await enabledModule.GetInstance().OnBeforeRunAsync(this, context, Args);
+// // if (!shouldContinue)
+// // {
+// // return;
+// // }
+// // }
+//
+// // LogInternal("Check required modules");
+// // var modulesCheckSuccess = true;
+// // foreach (var registration in enabledModules)
+// // {
+// // var result =
+// // registration.CheckRequiredModules(context,
+// // enabledModules.Select(r => r.Type).ToArray());
+// // if (!result.isSuccess)
+// // {
+// // foreach (var missingModule in result.missingModules)
+// // {
+// // LogInternal($"Required module {missingModule} for module {registration.Type} is not registered");
+// // }
+// //
+// // modulesCheckSuccess = false;
+// // }
+// // }
+//
+// // if (!modulesCheckSuccess)
+// // {
+// // LogInternal("Check required modules failed");
+// // return;
+// // }
+//
+// // foreach (var enabledModule in enabledModules)
+// // {
+// // var shouldContinue = await enabledModule.GetInstance().OnAfterRunAsync(this, context, Args);
+// // if (!shouldContinue)
+// // {
+// // return;
+// // }
+// // }
+//
+// //await DoRunAsync();
+// }
+//
+// protected abstract Task DoRunAsync();
+//
+// protected abstract Task BuildAppContextAsync();
+//
+// public abstract Task StopAsync();
+//
+// // protected async Task InitAsync(IServiceProvider serviceProvider)
+// // {
+// // LogInternal("Build and init async start");
+// // using var scope = serviceProvider.CreateScope();
+// // var logger = scope.ServiceProvider.GetRequiredService>();
+// // logger.LogInformation("Init modules");
+// // // var registrations = GetEnabledModuleRegistrations(GetContext(scope.ServiceProvider));
+// // // var context = GetContext(scope.ServiceProvider);
+// // // foreach (var configurationModule in registrations.Select(module => module.GetInstance())
+// // // .OfType())
+// // // {
+// // // configurationModule.CheckConfiguration(context, scope.ServiceProvider);
+// // // }
+// // //
+// // // foreach (var registration in registrations)
+// // // {
+// // // logger.LogInformation("Init module {Module}", registration.Type);
+// // // await registration.InitAsync(context, scope.ServiceProvider);
+// // // }
+// //
+// // LogInternal("Build and init async done");
+// // }
+//
+// protected virtual void LogInternal(string message) { }
+//
+// protected abstract bool CanAddModule();
+//
+// // [PublicAPI]
+// // protected void RegisterModule(
+// // Action? configureOptions = null,
+// // string? optionsKey = null)
+// // where TModule : IApplicationModule, new() where TModuleOptions : BaseModuleOptions, new()
+// // {
+// // if (!CanAddModule())
+// // {
+// // throw new InvalidOperationException("App host is already built. Can't add modules after it");
+// // }
+// //
+// // var instance = new TModule();
+// // if (!instance.AllowMultiple && HasModule())
+// // {
+// // throw new InvalidOperationException($"Module {typeof(TModule)} already registered");
+// // }
+// //
+// // moduleRegistrations.Add(
+// // new ApplicationModuleRegistration(instance, configureOptions, optionsKey));
+// // }
+//
+// // protected virtual void InitApplication()
+// // {
+// // }
+//
+//
+// // [PublicAPI]
+// // protected abstract IApplicationContext GetContext();
+// //
+// // [PublicAPI]
+// // protected abstract IApplicationContext GetContext(IServiceProvider serviceProvider);
+//
+//
+//
+//
+// public Application AddModule() where TModule : BaseApplicationModule, new()
+//
+// {
+// //RegisterModule();
+// return this;
+// }
+//
+// public Application AddModule(
+// Action configureOptions,
+// string? optionsKey = null)
+// where TModule : IApplicationModule, new()
+// where TModuleOptions : BaseModuleOptions, new()
+// {
+// //RegisterModule(configureOptions, optionsKey);
+// return this;
+// }
+//
+// public Application AddModule(
+// Action? configureOptions = null,
+// string? optionsKey = null)
+// where TModule : IApplicationModule, new()
+// where TModuleOptions : BaseModuleOptions, new() =>
+// AddModule((_, moduleOptions) =>
+// {
+// configureOptions?.Invoke(moduleOptions);
+// }, optionsKey);
+// }
diff --git a/src/Sitko.Core.App/ApplicationLifetimeService.cs b/src/Sitko.Core.App/ApplicationLifetimeService.cs
deleted file mode 100644
index f5c4f7624..000000000
--- a/src/Sitko.Core.App/ApplicationLifetimeService.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Microsoft.Extensions.Hosting;
-
-namespace Sitko.Core.App;
-
-public class ApplicationLifetimeService : BackgroundService
-{
- /*private readonly Application application;
- private readonly IApplicationContext applicationContext;
- private readonly IHostApplicationLifetime hostApplicationLifetime;
- private readonly IServiceProvider serviceProvider;
-
- public ApplicationLifetimeService(IHostApplicationLifetime hostApplicationLifetime,
- IServiceProvider serviceProvider, Application application, IApplicationContext applicationContext)
- {
- this.hostApplicationLifetime = hostApplicationLifetime;
- this.serviceProvider = serviceProvider;
- this.application = application;
- this.applicationContext = applicationContext;
- }*/
-
- protected override Task ExecuteAsync(CancellationToken stoppingToken)
- {
- // ReSharper disable once AsyncVoidLambda
- // hostApplicationLifetime.ApplicationStarted.Register(async () =>
- // await application.OnStarted(applicationContext, serviceProvider));
- // // ReSharper disable once AsyncVoidLambda
- // hostApplicationLifetime.ApplicationStopping.Register(async () =>
- // await application.OnStopping(applicationContext, serviceProvider));
- // // ReSharper disable once AsyncVoidLambda
- // hostApplicationLifetime.ApplicationStopped.Register(async () =>
- // await application.OnStopped(applicationContext, serviceProvider));
-
- return Task.CompletedTask;
- }
-}
-
diff --git a/src/Sitko.Core.App/BuilderApplicationContext.cs b/src/Sitko.Core.App/BuilderApplicationContext.cs
index 4ac441b2b..077099245 100644
--- a/src/Sitko.Core.App/BuilderApplicationContext.cs
+++ b/src/Sitko.Core.App/BuilderApplicationContext.cs
@@ -1,5 +1,4 @@
using System.Globalization;
-using System.Linq.Expressions;
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@@ -41,6 +40,12 @@ public BuilderApplicationContext(IConfiguration configuration, IHostEnvironment
public IConfiguration Configuration { get; }
public ILogger Logger { get; }
+ public string AspNetEnvironmentName => environment.EnvironmentName;
+ public bool IsDevelopment() => environment.IsDevelopment();
+
+ public bool IsProduction() => environment.IsProduction();
+ public string[] Args { get; }
+
private ApplicationOptions GetApplicationOptions()
{
if (applicationOptions is not null)
@@ -49,7 +54,7 @@ private ApplicationOptions GetApplicationOptions()
}
applicationOptions = new ApplicationOptions();
- Configuration.Bind(Application.OptionsKey, applicationOptions);
+ Configuration.Bind(SitkoCoreApplicationBuilder.OptionsKey, applicationOptions);
if (string.IsNullOrEmpty(applicationOptions.Name))
{
applicationOptions.Name = Assembly.GetEntryAssembly()?.GetName().Name ?? "App";
@@ -69,12 +74,6 @@ private ApplicationOptions GetApplicationOptions()
return applicationOptions;
}
- public string AspNetEnvironmentName => environment.EnvironmentName;
- public bool IsDevelopment() => environment.IsDevelopment();
-
- public bool IsProduction() => environment.IsProduction();
- public string[] Args { get; }
-
protected void ConfigureApplicationOptions(ApplicationOptions options) =>
options.EnableConsoleLogging ??= environment.IsDevelopment();
}
diff --git a/src/Sitko.Core.App/Helpers/DictionaryExtensions.cs b/src/Sitko.Core.App/Helpers/DictionaryExtensions.cs
new file mode 100644
index 000000000..7ae5523f6
--- /dev/null
+++ b/src/Sitko.Core.App/Helpers/DictionaryExtensions.cs
@@ -0,0 +1,15 @@
+namespace Sitko.Core.App.Helpers;
+
+public static class DictionaryExtensions
+{
+ public static TValue GetOrCreate(this IDictionary dict, TKey key, Func factory)
+ {
+ if (!dict.TryGetValue(key, out var val))
+ {
+ val = factory();
+ dict.Add(key, val);
+ }
+
+ return val;
+ }
+}
diff --git a/src/Sitko.Core.App/HostApplicationBuilderExtensions.cs b/src/Sitko.Core.App/HostApplicationBuilderExtensions.cs
index d67c9b02a..8420449f5 100644
--- a/src/Sitko.Core.App/HostApplicationBuilderExtensions.cs
+++ b/src/Sitko.Core.App/HostApplicationBuilderExtensions.cs
@@ -1,9 +1,16 @@
+using System.Collections.Concurrent;
using Microsoft.Extensions.Hosting;
namespace Sitko.Core.App;
public static class HostApplicationBuilderExtensions
{
+ private static readonly ConcurrentDictionary Builders = new();
+
+ public static SitkoCoreApplicationBuilder
+ AddSitkoCore(this IHostApplicationBuilder builder) =>
+ builder.AddSitkoCore(Array.Empty());
+
public static SitkoCoreApplicationBuilder AddSitkoCore(this IHostApplicationBuilder builder, string[] args) =>
- new(builder, args);
+ Builders.GetOrAdd(builder, _ => new SitkoCoreApplicationBuilder(builder, args));
}
diff --git a/src/Sitko.Core.App/HostedApplication.cs b/src/Sitko.Core.App/HostedApplication.cs
index bd25ecde9..9e6ed1685 100644
--- a/src/Sitko.Core.App/HostedApplication.cs
+++ b/src/Sitko.Core.App/HostedApplication.cs
@@ -1,248 +1,248 @@
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Hosting;
-
-namespace Sitko.Core.App;
-
-public abstract class HostedApplication : Application
-{
-// private IHost? appHost;
-
- protected HostedApplication(string[] args) : base(args)
- {
-// Console.OutputEncoding = Encoding.UTF8;
- // var loggerConfiguration = new LoggerConfiguration();
- // loggerConfiguration
- // .WriteTo.Console(outputTemplate: ApplicationOptions.BaseConsoleLogFormat,
- // formatProvider: CultureInfo.InvariantCulture,
- // restrictedToMinimumLevel: LogEventLevel.Debug);
- // InternalLogger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger();
- }
-
- /*protected ILogger InternalLogger { get; }
-
- protected virtual IHostBuilder CreateHostBuilderBase(string[] hostBuilderArgs) =>
- Host.CreateDefaultBuilder(hostBuilderArgs);
-
- private IHostBuilder CreateHostBuilder(string[] hostBuilderArgs)
- {
- var builder = CreateHostBuilderBase(hostBuilderArgs);
- ConfigureHostBuilder(builder);
- return builder;
- }
-
- protected virtual void ConfigureHostBuilder(IHostBuilder builder)
- {
- builder.ConfigureHostConfiguration(ConfigureHostConfiguration);
- builder.ConfigureAppConfiguration(ConfigureAppConfiguration);
- }
-
- protected override void LogInternal(string message) =>
- InternalLogger.LogInformation("Check log: {Message}", message);*/
-
- // protected IHost CreateAppHost(Action? configure = null)
- // {
- // LogInternal("Create app host start");
- //
- // if (appHost is not null)
- // {
- // LogInternal("App host is already built");
- //
- // return appHost;
- // }
- //
- // LogInternal("Configure host builder");
- //
- // var hostBuilder = ConfigureHostBuilder(configure);
- //
- // LogInternal("Build host");
- // var newHost = hostBuilder.Build();
- //
- // appHost = newHost;
- // LogInternal("Create app host done");
- // return appHost;
- // }
-
- // protected IApplicationContext GetContext(IHostEnvironment environment, IConfiguration configuration) =>
- // new HostedApplicationContext(this, configuration, environment);
-
- // protected IHostBuilder ConfigureHostBuilder(Action? configure = null)
- // {
- // // LogInternal("Configure host builder start");
- // //
- // // LogInternal("Create tmp host builder");
- // //
- // // var startEnvironment = new HostingEnvironment
- // // {
- // // ApplicationName = GetType().Assembly.FullName!, EnvironmentName = EnvHelper.GetEnvironmentName()
- // // };
- // //
- // // var configBuilder = new ConfigurationBuilder()
- // // .AddEnvironmentVariables()
- // // .AddEnvironmentVariables("DOTNET_")
- // // .AddEnvironmentVariables("ASPNETCORE_")
- // // .AddJsonFile("appsettings.json", true, false)
- // // .AddJsonFile($"appsettings.{startEnvironment.EnvironmentName}.json", true, false);
- // // var startApplicationContext = GetContext(startEnvironment, configBuilder.Build());
- // // ConfigureConfiguration(startApplicationContext, configBuilder);
- //
- // //LogInternal("Init application");
- //
- // //InitApplication();
- //
- // // LogInternal("Create main host builder");
- // // var hostBuilder = CreateHostBuilder(Args)
- // // .UseDefaultServiceProvider(options =>
- // // {
- // // options.ValidateOnBuild = true;
- // // options.ValidateScopes = true;
- // // });
- //
- // //LogInternal("Configure host builder in modules");
- // //var bootConfiguration = configBuilder.Build();
- // // var bootEnvironment = new HostingEnvironment
- // // {
- // // ApplicationName = bootConfiguration[HostDefaults.ApplicationKey] ?? "",
- // // EnvironmentName = bootConfiguration[HostDefaults.EnvironmentKey] ?? Environments.Production
- // // };
- // //var bootApplicationContext = GetContext(bootEnvironment, bootConfiguration);
- //
- // // foreach (var moduleRegistration in GetEnabledModuleRegistrations(bootApplicationContext))
- // // {
- // // moduleRegistration.ConfigureHostBuilder(bootApplicationContext, hostBuilder);
- // // }
- //
- // //LogInternal("Configure host builder");
- // // hostBuilder.ConfigureAppConfiguration((_, builder) =>
- // // {
- // // //ConfigureConfiguration(bootApplicationContext, builder);
- // // })
- // // // .ConfigureServices((_, services) =>
- // // // {
- // // // //RegisterApplicationServices(bootApplicationContext, services);
- // // // //services.AddHostedService();
- // // // })
- // // .ConfigureLogging((builderContext, builder) =>
- // // {
- // // // LogInternal("Configure logging");
- // // // var runtimeContext = GetContext(builderContext.HostingEnvironment, builderContext.Configuration);
- // // // LoggingExtensions.ConfigureSerilog(runtimeContext, builder,
- // // // configuration =>
- // // // {
- // // // configuration = configuration.Enrich.WithMachineName();
- // // // if (runtimeContext.Options.EnableConsoleLogging == true)
- // // // {
- // // // configuration = configuration.WriteTo.Console(
- // // // outputTemplate: runtimeContext.Options.ConsoleLogFormat,
- // // // formatProvider: CultureInfo.InvariantCulture);
- // // // }
- // // //
- // // // return ConfigureLogging(runtimeContext, configuration);
- // // // });
- // // });
- // //configure?.Invoke(hostBuilder);
- // //PostConfigureHostBuilder(bootApplicationContext, hostBuilder);
- // // foreach (var moduleRegistration in GetEnabledModuleRegistrations(bootApplicationContext))
- // // {
- // // moduleRegistration.PostConfigureHostBuilder(bootApplicationContext, hostBuilder);
- // // }
- // LogInternal("Create host builder done");
- // return hostBuilder;
- // }
-
- // protected virtual void PostConfigureHostBuilder(IApplicationContext applicationContext, IHostBuilder hostBuilder)
- // {
- // }
- //
- // protected override async ValueTask DisposeAsync(bool disposing)
- // {
- // await base.DisposeAsync(disposing);
- // if (disposing)
- // {
- // appHost?.Dispose();
- // }
- // }
-
- // public async Task ExecuteAsync(Func command)
- // {
- // var currentHost = await GetOrCreateHostAsync(builder => builder.UseConsoleLifetime());
- //
- // var serviceProvider = currentHost.Services;
- //
- // try
- // {
- // using var scope = serviceProvider.CreateScope();
- // await command(scope.ServiceProvider);
- // }
- // catch (Exception ex)
- // {
- // var logger = serviceProvider.GetRequiredService>();
- // logger.LogError(ex, "Error: {ErrorText}", ex.ToString());
- // }
- // }
-
-
- //public override Task StopAsync() => CreateAppHost().StopAsync();
- // protected override bool CanAddModule() => appHost is null;
- //public IHostBuilder GetHostBuilder() => ConfigureHostBuilder();
-
- // protected override IApplicationContext GetContext() => appHost is not null
- // ? GetContext(appHost.Services)
- // : throw new InvalidOperationException("App host is not built yet");
-
- // protected async Task GetOrCreateHostAsync(Action? configure = null)
- // {
- // if (appHost is not null)
- // {
- // return appHost;
- // }
- //
- // appHost = CreateAppHost(configure);
- //
- // await InitAsync(appHost.Services);
- //
- // return appHost;
- // }
-
- // protected override async Task BuildAppContextAsync()
- // {
- // var currentHost = await GetOrCreateHostAsync();
- // return GetContext(currentHost.Services);
- // }
- //
- // public async Task StartAsync()
- // {
- // var currentHost = await GetOrCreateHostAsync();
- // await currentHost.StartAsync();
- // return currentHost;
- // }
- //
- // protected override async Task DoRunAsync()
- // {
- // var currentHost = await GetOrCreateHostAsync();
- // await currentHost.RunAsync();
- // }
- //
- // public async Task GetServiceProviderAsync() => (await GetOrCreateHostAsync()).Services;
-
- // protected override IApplicationContext GetContext(IServiceProvider serviceProvider) => GetContext(
- // serviceProvider.GetRequiredService(),
- // serviceProvider.GetRequiredService());
-}
-
-// public class HostedApplicationContext : BaseApplicationContext
+// using Microsoft.Extensions.Configuration;
+// using Microsoft.Extensions.Hosting;
+//
+// namespace Sitko.Core.App;
+//
+// public abstract class HostedApplication : Application
// {
-// private readonly IHostEnvironment environment;
+// // private IHost? appHost;
+//
+// protected HostedApplication(string[] args) : base(args)
+// {
+// // Console.OutputEncoding = Encoding.UTF8;
+// // var loggerConfiguration = new LoggerConfiguration();
+// // loggerConfiguration
+// // .WriteTo.Console(outputTemplate: ApplicationOptions.BaseConsoleLogFormat,
+// // formatProvider: CultureInfo.InvariantCulture,
+// // restrictedToMinimumLevel: LogEventLevel.Debug);
+// // InternalLogger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger();
+// }
+//
+// /*protected ILogger InternalLogger { get; }
+//
+// protected virtual IHostBuilder CreateHostBuilderBase(string[] hostBuilderArgs) =>
+// Host.CreateDefaultBuilder(hostBuilderArgs);
+//
+// private IHostBuilder CreateHostBuilder(string[] hostBuilderArgs)
+// {
+// var builder = CreateHostBuilderBase(hostBuilderArgs);
+// ConfigureHostBuilder(builder);
+// return builder;
+// }
+//
+// protected virtual void ConfigureHostBuilder(IHostBuilder builder)
+// {
+// builder.ConfigureHostConfiguration(ConfigureHostConfiguration);
+// builder.ConfigureAppConfiguration(ConfigureAppConfiguration);
+// }
+//
+// protected override void LogInternal(string message) =>
+// InternalLogger.LogInformation("Check log: {Message}", message);*/
//
-// public HostedApplicationContext(Application application, IConfiguration configuration, IHostEnvironment environment)
-// : base(application,
-// configuration) =>
-// this.environment = environment;
+// // protected IHost CreateAppHost(Action? configure = null)
+// // {
+// // LogInternal("Create app host start");
+// //
+// // if (appHost is not null)
+// // {
+// // LogInternal("App host is already built");
+// //
+// // return appHost;
+// // }
+// //
+// // LogInternal("Configure host builder");
+// //
+// // var hostBuilder = ConfigureHostBuilder(configure);
+// //
+// // LogInternal("Build host");
+// // var newHost = hostBuilder.Build();
+// //
+// // appHost = newHost;
+// // LogInternal("Create app host done");
+// // return appHost;
+// // }
//
-// public override string AspNetEnvironmentName => environment.EnvironmentName;
-// public override bool IsDevelopment() => environment.IsDevelopment();
+// // protected IApplicationContext GetContext(IHostEnvironment environment, IConfiguration configuration) =>
+// // new HostedApplicationContext(this, configuration, environment);
//
-// public override bool IsProduction() => environment.IsProduction();
+// // protected IHostBuilder ConfigureHostBuilder(Action? configure = null)
+// // {
+// // // LogInternal("Configure host builder start");
+// // //
+// // // LogInternal("Create tmp host builder");
+// // //
+// // // var startEnvironment = new HostingEnvironment
+// // // {
+// // // ApplicationName = GetType().Assembly.FullName!, EnvironmentName = EnvHelper.GetEnvironmentName()
+// // // };
+// // //
+// // // var configBuilder = new ConfigurationBuilder()
+// // // .AddEnvironmentVariables()
+// // // .AddEnvironmentVariables("DOTNET_")
+// // // .AddEnvironmentVariables("ASPNETCORE_")
+// // // .AddJsonFile("appsettings.json", true, false)
+// // // .AddJsonFile($"appsettings.{startEnvironment.EnvironmentName}.json", true, false);
+// // // var startApplicationContext = GetContext(startEnvironment, configBuilder.Build());
+// // // ConfigureConfiguration(startApplicationContext, configBuilder);
+// //
+// // //LogInternal("Init application");
+// //
+// // //InitApplication();
+// //
+// // // LogInternal("Create main host builder");
+// // // var hostBuilder = CreateHostBuilder(Args)
+// // // .UseDefaultServiceProvider(options =>
+// // // {
+// // // options.ValidateOnBuild = true;
+// // // options.ValidateScopes = true;
+// // // });
+// //
+// // //LogInternal("Configure host builder in modules");
+// // //var bootConfiguration = configBuilder.Build();
+// // // var bootEnvironment = new HostingEnvironment
+// // // {
+// // // ApplicationName = bootConfiguration[HostDefaults.ApplicationKey] ?? "",
+// // // EnvironmentName = bootConfiguration[HostDefaults.EnvironmentKey] ?? Environments.Production
+// // // };
+// // //var bootApplicationContext = GetContext(bootEnvironment, bootConfiguration);
+// //
+// // // foreach (var moduleRegistration in GetEnabledModuleRegistrations(bootApplicationContext))
+// // // {
+// // // moduleRegistration.ConfigureHostBuilder(bootApplicationContext, hostBuilder);
+// // // }
+// //
+// // //LogInternal("Configure host builder");
+// // // hostBuilder.ConfigureAppConfiguration((_, builder) =>
+// // // {
+// // // //ConfigureConfiguration(bootApplicationContext, builder);
+// // // })
+// // // // .ConfigureServices((_, services) =>
+// // // // {
+// // // // //RegisterApplicationServices(bootApplicationContext, services);
+// // // // //services.AddHostedService();
+// // // // })
+// // // .ConfigureLogging((builderContext, builder) =>
+// // // {
+// // // // LogInternal("Configure logging");
+// // // // var runtimeContext = GetContext(builderContext.HostingEnvironment, builderContext.Configuration);
+// // // // LoggingExtensions.ConfigureSerilog(runtimeContext, builder,
+// // // // configuration =>
+// // // // {
+// // // // configuration = configuration.Enrich.WithMachineName();
+// // // // if (runtimeContext.Options.EnableConsoleLogging == true)
+// // // // {
+// // // // configuration = configuration.WriteTo.Console(
+// // // // outputTemplate: runtimeContext.Options.ConsoleLogFormat,
+// // // // formatProvider: CultureInfo.InvariantCulture);
+// // // // }
+// // // //
+// // // // return ConfigureLogging(runtimeContext, configuration);
+// // // // });
+// // // });
+// // //configure?.Invoke(hostBuilder);
+// // //PostConfigureHostBuilder(bootApplicationContext, hostBuilder);
+// // // foreach (var moduleRegistration in GetEnabledModuleRegistrations(bootApplicationContext))
+// // // {
+// // // moduleRegistration.PostConfigureHostBuilder(bootApplicationContext, hostBuilder);
+// // // }
+// // LogInternal("Create host builder done");
+// // return hostBuilder;
+// // }
//
-// protected override void ConfigureApplicationOptions(ApplicationOptions options) =>
-// options.EnableConsoleLogging ??= environment.IsDevelopment();
+// // protected virtual void PostConfigureHostBuilder(IApplicationContext applicationContext, IHostBuilder hostBuilder)
+// // {
+// // }
+// //
+// // protected override async ValueTask DisposeAsync(bool disposing)
+// // {
+// // await base.DisposeAsync(disposing);
+// // if (disposing)
+// // {
+// // appHost?.Dispose();
+// // }
+// // }
+//
+// // public async Task ExecuteAsync(Func command)
+// // {
+// // var currentHost = await GetOrCreateHostAsync(builder => builder.UseConsoleLifetime());
+// //
+// // var serviceProvider = currentHost.Services;
+// //
+// // try
+// // {
+// // using var scope = serviceProvider.CreateScope();
+// // await command(scope.ServiceProvider);
+// // }
+// // catch (Exception ex)
+// // {
+// // var logger = serviceProvider.GetRequiredService>();
+// // logger.LogError(ex, "Error: {ErrorText}", ex.ToString());
+// // }
+// // }
+//
+//
+// //public override Task StopAsync() => CreateAppHost().StopAsync();
+// // protected override bool CanAddModule() => appHost is null;
+// //public IHostBuilder GetHostBuilder() => ConfigureHostBuilder();
+//
+// // protected override IApplicationContext GetContext() => appHost is not null
+// // ? GetContext(appHost.Services)
+// // : throw new InvalidOperationException("App host is not built yet");
+//
+// // protected async Task GetOrCreateHostAsync(Action? configure = null)
+// // {
+// // if (appHost is not null)
+// // {
+// // return appHost;
+// // }
+// //
+// // appHost = CreateAppHost(configure);
+// //
+// // await InitAsync(appHost.Services);
+// //
+// // return appHost;
+// // }
+//
+// // protected override async Task BuildAppContextAsync()
+// // {
+// // var currentHost = await GetOrCreateHostAsync();
+// // return GetContext(currentHost.Services);
+// // }
+// //
+// // public async Task StartAsync()
+// // {
+// // var currentHost = await GetOrCreateHostAsync();
+// // await currentHost.StartAsync();
+// // return currentHost;
+// // }
+// //
+// // protected override async Task DoRunAsync()
+// // {
+// // var currentHost = await GetOrCreateHostAsync();
+// // await currentHost.RunAsync();
+// // }
+// //
+// // public async Task GetServiceProviderAsync() => (await GetOrCreateHostAsync()).Services;
+//
+// // protected override IApplicationContext GetContext(IServiceProvider serviceProvider) => GetContext(
+// // serviceProvider.GetRequiredService(),
+// // serviceProvider.GetRequiredService());
// }
+//
+// // public class HostedApplicationContext : BaseApplicationContext
+// // {
+// // private readonly IHostEnvironment environment;
+// //
+// // public HostedApplicationContext(Application application, IConfiguration configuration, IHostEnvironment environment)
+// // : base(application,
+// // configuration) =>
+// // this.environment = environment;
+// //
+// // public override string AspNetEnvironmentName => environment.EnvironmentName;
+// // public override bool IsDevelopment() => environment.IsDevelopment();
+// //
+// // public override bool IsProduction() => environment.IsProduction();
+// //
+// // protected override void ConfigureApplicationOptions(ApplicationOptions options) =>
+// // options.EnableConsoleLogging ??= environment.IsDevelopment();
+// // }
diff --git a/src/Sitko.Core.App/IApplication.cs b/src/Sitko.Core.App/IApplication.cs
deleted file mode 100644
index e998bcad6..000000000
--- a/src/Sitko.Core.App/IApplication.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Sitko.Core.App;
-
-public interface IApplication
-{
- // string Name { get; }
- // string Version { get; }
-}
-
diff --git a/src/Sitko.Core.App/IApplicationContext.cs b/src/Sitko.Core.App/IApplicationContext.cs
index 49cce50be..90b908890 100644
--- a/src/Sitko.Core.App/IApplicationContext.cs
+++ b/src/Sitko.Core.App/IApplicationContext.cs
@@ -1,10 +1,5 @@
-using System.Globalization;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
-using Serilog;
-using Serilog.Events;
-using Serilog.Extensions.Logging;
-using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace Sitko.Core.App;
@@ -18,73 +13,7 @@ public interface IApplicationContext
ILogger Logger { get; }
string Environment { get; }
string AspNetEnvironmentName { get; }
+ public string[] Args { get; }
bool IsDevelopment();
bool IsProduction();
- public string[] Args { get; }
-}
-
-public abstract class BaseApplicationContext : IApplicationContext
-{
- private readonly Application application;
- private ApplicationOptions? applicationOptions;
-
- protected BaseApplicationContext(Application application, IConfiguration configuration)
- {
- this.application = application;
- Configuration = configuration;
- var loggerConfiguration = new LoggerConfiguration();
- loggerConfiguration
- .WriteTo.Console(outputTemplate: ApplicationOptions.BaseConsoleLogFormat,
- formatProvider: CultureInfo.InvariantCulture,
- restrictedToMinimumLevel: LogEventLevel.Debug);
- Logger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger();
- }
-
- public ApplicationOptions Options => GetApplicationOptions();
-
- public Guid Id { get; } = Guid.NewGuid();
- public string Name => Options.Name;
- public string Version => Options.Version;
- public string Environment => Options.Environment;
-
- public IConfiguration Configuration { get; }
- public ILogger Logger { get; }
- public abstract string AspNetEnvironmentName { get; }
- public abstract bool IsDevelopment();
-
- public abstract bool IsProduction();
- public string[] Args { get; }
-
- private ApplicationOptions GetApplicationOptions()
- {
- if (applicationOptions is not null)
- {
- return applicationOptions;
- }
-
- applicationOptions = new ApplicationOptions();
- Configuration.Bind(Application.OptionsKey, applicationOptions);
- if (string.IsNullOrEmpty(applicationOptions.Name))
- {
- applicationOptions.Name = application.GetType().Assembly.GetName().Name ?? "App";
- }
-
- if (string.IsNullOrEmpty(applicationOptions.Version))
- {
- applicationOptions.Version = application.GetType().Assembly.GetName().Version?.ToString() ?? "dev";
- }
-
- if (string.IsNullOrEmpty(applicationOptions.Environment))
- {
- applicationOptions.Environment = AspNetEnvironmentName;
- }
-
- ConfigureApplicationOptions(applicationOptions);
- return applicationOptions;
- }
-
- protected virtual void ConfigureApplicationOptions(ApplicationOptions options)
- {
- }
}
-
diff --git a/src/Sitko.Core.App/Localization/ApplicationExtensions.cs b/src/Sitko.Core.App/Localization/ApplicationExtensions.cs
index 30aeb0c5d..f9b14debd 100644
--- a/src/Sitko.Core.App/Localization/ApplicationExtensions.cs
+++ b/src/Sitko.Core.App/Localization/ApplicationExtensions.cs
@@ -1,17 +1,32 @@
using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
namespace Sitko.Core.App.Localization;
[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddJsonLocalization(this Application application,
+ public static IHostApplicationBuilder AddJsonLocalization(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddJsonLocalization(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddJsonLocalization(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddJsonLocalization(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddJsonLocalization(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure,
string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddJsonLocalization(this Application application,
+ public static SitkoCoreApplicationBuilder AddJsonLocalization(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.App/SitkoCoreApplicationBuilder.cs b/src/Sitko.Core.App/SitkoCoreApplicationBuilder.cs
index 250a2c2cb..1921e7753 100644
--- a/src/Sitko.Core.App/SitkoCoreApplicationBuilder.cs
+++ b/src/Sitko.Core.App/SitkoCoreApplicationBuilder.cs
@@ -15,17 +15,16 @@ namespace Sitko.Core.App;
public class SitkoCoreApplicationBuilder
{
+ public static string OptionsKey => "Application";
protected IApplicationContext BootApplicationContext { get; }
- protected IHostApplicationBuilder builder { get; }
+ protected IHostApplicationBuilder Builder { get; }
private readonly List moduleRegistrations =
new();
- private bool isBuilt;
-
public SitkoCoreApplicationBuilder(IHostApplicationBuilder builder, string[] args)
{
- this.builder = builder;
+ this.Builder = builder;
var bootConfig = builder.Configuration.Build();
var argsProvider = new ApplicationArgsProvider(args);
BootApplicationContext = new BuilderApplicationContext(bootConfig, builder.Environment, argsProvider);
@@ -37,7 +36,6 @@ public SitkoCoreApplicationBuilder(IHostApplicationBuilder builder, string[] arg
builder.Services.AddTransient();
builder.Services.AddFluentValidationExtensions();
builder.Services.AddTransient(typeof(ILocalizationProvider<>), typeof(LocalizationProvider<>));
- builder.Services.AddHostedService(); // только Hosted? Проверить для Wasm
builder.Services.AddHostedService(); // только Hosted? Проверить для Wasm
Console.OutputEncoding = Encoding.UTF8;
@@ -46,21 +44,23 @@ public SitkoCoreApplicationBuilder(IHostApplicationBuilder builder, string[] arg
.WriteTo.Console(outputTemplate: ApplicationOptions.BaseConsoleLogFormat,
formatProvider: CultureInfo.InvariantCulture,
restrictedToMinimumLevel: LogEventLevel.Debug);
- InternalLogger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger();
+ InternalLogger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger())
+ .CreateLogger();
AddModule();
}
- protected ILogger InternalLogger { get; }
+ protected ILogger InternalLogger { get; }
protected Dictionary LogEventLevels { get; } = new();
protected List>
LoggerConfigurationActions { get; } = new();
+ // TODO: WHEN?
private void ConfigureLogging()
{
LogInternal("Configure logging");
- LoggingExtensions.ConfigureSerilog(BootApplicationContext, builder.Logging,
+ LoggingExtensions.ConfigureSerilog(BootApplicationContext, Builder.Logging,
configuration =>
{
configuration = configuration.Enrich.WithMachineName();
@@ -129,7 +129,7 @@ public SitkoCoreApplicationBuilder AddModule(
public bool HasModule() where TModule : IApplicationModule =>
moduleRegistrations.Any(r => r.Type == typeof(TModule));
- private bool CanAddModule() => !isBuilt;
+ private bool CanAddModule() => moduleRegistrations.Count < 100500; // TODO: still needed?
private void RegisterModule(
Action? configureOptions = null,
@@ -155,22 +155,22 @@ private void RegisterModule(
ConfigureHostBuilder(registration);
}
- registration.ConfigureAppConfiguration(BootApplicationContext, builder.Configuration);
- registration.ConfigureOptions(BootApplicationContext, builder.Services);
- registration.ConfigureServices(BootApplicationContext, builder.Services);
+ registration.ConfigureAppConfiguration(BootApplicationContext, Builder.Configuration);
+ registration.ConfigureOptions(BootApplicationContext, Builder.Services);
+ registration.ConfigureServices(BootApplicationContext, Builder.Services);
if (typeof(TModule).IsAssignableTo(typeof(IHostBuilderModule)))
{
- registration.PostConfigureHostBuilder(BootApplicationContext, builder);
+ registration.PostConfigureHostBuilder(BootApplicationContext, Builder);
}
moduleRegistrations.Add(registration);
- builder.Services.AddSingleton(registration);
+ Builder.Services.AddSingleton(registration);
}
protected virtual void ConfigureHostBuilder(ApplicationModuleRegistration registration)
where TModule : IApplicationModule, new() where TModuleOptions : BaseModuleOptions, new() =>
- registration.ConfigureHostBuilder(BootApplicationContext, builder);
+ registration.ConfigureHostBuilder(BootApplicationContext, Builder);
public SitkoCoreApplicationBuilder ConfigureLogLevel(string source, LogEventLevel level)
{
@@ -184,4 +184,10 @@ public SitkoCoreApplicationBuilder ConfigureLogging(
LoggerConfigurationActions.Add(configure);
return this;
}
+
+ public SitkoCoreApplicationBuilder ConfigureServices(Action configure)
+ {
+ configure(Builder.Services);
+ return this;
+ }
}
diff --git a/src/Sitko.Core.Auth.Basic/ApplicationExtensions.cs b/src/Sitko.Core.Auth.Basic/ApplicationExtensions.cs
index 2660d94d1..53a676c03 100644
--- a/src/Sitko.Core.Auth.Basic/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Auth.Basic/ApplicationExtensions.cs
@@ -1,15 +1,31 @@
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
namespace Sitko.Core.Auth.Basic;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddBasicAuth(this Application application,
+ public static IHostApplicationBuilder AddBasicAuth(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddBasicAuth(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddBasicAuth(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddBasicAuth(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddBasicAuth(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddBasicAuth(this Application application,
+ public static SitkoCoreApplicationBuilder AddBasicAuth(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.Auth.Google/ApplicationExtensions.cs b/src/Sitko.Core.Auth.Google/ApplicationExtensions.cs
index e5c2ab6f8..e047e4ed7 100644
--- a/src/Sitko.Core.Auth.Google/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Auth.Google/ApplicationExtensions.cs
@@ -1,15 +1,31 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Auth.Google;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddGoogleAuth(this Application application,
+ public static IHostApplicationBuilder AddGoogleAuth(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddGoogleAuth(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddGoogleAuth(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddGoogleAuth(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddGoogleAuth(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddGoogleAuth(this Application application,
+ public static SitkoCoreApplicationBuilder AddGoogleAuth(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.Auth.IdentityServer/ApplicationExtensions.cs b/src/Sitko.Core.Auth.IdentityServer/ApplicationExtensions.cs
index 5d8d8158b..cd91bc83f 100644
--- a/src/Sitko.Core.Auth.IdentityServer/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Auth.IdentityServer/ApplicationExtensions.cs
@@ -1,29 +1,61 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Auth.IdentityServer;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddJwtIdentityServer(this Application application,
+ public static IHostApplicationBuilder AddJwtIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddJwtIdentityServer(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddJwtIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddJwtIdentityServer(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddOidcIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddOidcIdentityServer(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddOidcIdentityServer(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddOidcIdentityServer(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddJwtIdentityServer(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure,
string? optionsKey = null) =>
- application
+ applicationBuilder
.AddModule(configure, optionsKey);
- public static Application AddJwtIdentityServer(this Application application,
+ public static SitkoCoreApplicationBuilder AddJwtIdentityServer(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application
+ applicationBuilder
.AddModule(configure, optionsKey);
- public static Application AddOidcIdentityServer(this Application application,
+ public static SitkoCoreApplicationBuilder AddOidcIdentityServer(this SitkoCoreApplicationBuilder application,
Action configure,
string? optionsKey = null) =>
application.AddModule(configure,
optionsKey);
- public static Application AddOidcIdentityServer(this Application application,
+ public static SitkoCoreApplicationBuilder AddOidcIdentityServer(this SitkoCoreApplicationBuilder application,
Action? configure = null, string? optionsKey = null) =>
application.AddModule(configure,
optionsKey);
}
-
diff --git a/src/Sitko.Core.Automapper/ApplicationExtensions.cs b/src/Sitko.Core.Automapper/ApplicationExtensions.cs
index 57a6d0853..8e14b53ac 100644
--- a/src/Sitko.Core.Automapper/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Automapper/ApplicationExtensions.cs
@@ -1,17 +1,35 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Automapper;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddAutoMapper(this Application application,
+ public static IHostApplicationBuilder AddAutoMapper(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddAutoMapper(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddAutoMapper(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddAutoMapper(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddAutoMapper(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure,
string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddAutoMapper(this Application application,
+ public static SitkoCoreApplicationBuilder AddAutoMapper(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null,
string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.Blazor.AntDesign.Server/AntBlazorApplication.cs b/src/Sitko.Core.Blazor.AntDesign.Server/AntBlazorApplication.cs
deleted file mode 100644
index 26705c290..000000000
--- a/src/Sitko.Core.Blazor.AntDesign.Server/AntBlazorApplication.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Sitko.Core.Blazor.FileUpload;
-using Sitko.Core.Blazor.Server;
-
-namespace Sitko.Core.Blazor.AntDesign.Server;
-
-public class AntBlazorApplication : BlazorApplication where TStartup : AntBlazorStartup
-{
- public AntBlazorApplication(string[] args) : base(args) => this.AddBlazorFileUpload();
-}
diff --git a/src/Sitko.Core.Blazor.AntDesign.Server/ApplicationExtensions.cs b/src/Sitko.Core.Blazor.AntDesign.Server/ApplicationExtensions.cs
new file mode 100644
index 000000000..682bc9095
--- /dev/null
+++ b/src/Sitko.Core.Blazor.AntDesign.Server/ApplicationExtensions.cs
@@ -0,0 +1,21 @@
+using JetBrains.Annotations;
+using Microsoft.AspNetCore.Builder;
+using Sitko.Core.App;
+using Sitko.Core.Blazor.FileUpload;
+using Sitko.Core.Blazor.Server;
+
+namespace Sitko.Core.Blazor.AntDesign.Server;
+
+[PublicAPI]
+public static class ApplicationExtensions
+{
+ public static WebApplicationBuilder AddAntBlazorServer(this WebApplicationBuilder webApplicationBuilder)
+ {
+ webApplicationBuilder.AddSitkoCore().AddAntBlazorServer();
+ return webApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder
+ AddAntBlazorServer(this SitkoCoreApplicationBuilder webApplicationBuilder) =>
+ webApplicationBuilder.AddBlazorServer().AddBlazorFileUpload();
+}
diff --git a/src/Sitko.Core.Blazor.FileUpload/ApplicationExtensions.cs b/src/Sitko.Core.Blazor.FileUpload/ApplicationExtensions.cs
index 9cc06cd13..aa2cb34a3 100644
--- a/src/Sitko.Core.Blazor.FileUpload/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Blazor.FileUpload/ApplicationExtensions.cs
@@ -1,10 +1,19 @@
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
namespace Sitko.Core.Blazor.FileUpload;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddBlazorFileUpload(this Application application) =>
- application.AddModule();
+ public static IHostApplicationBuilder AddBlazorFileUpload(this IHostApplicationBuilder hostApplicationBuilder)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddBlazorFileUpload();
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddBlazorFileUpload(this SitkoCoreApplicationBuilder applicationBuilder) =>
+ applicationBuilder.AddModule();
}
diff --git a/src/Sitko.Core.Blazor.MudBlazor.Server/ApplicationExtensions.cs b/src/Sitko.Core.Blazor.MudBlazor.Server/ApplicationExtensions.cs
new file mode 100644
index 000000000..e56b4c078
--- /dev/null
+++ b/src/Sitko.Core.Blazor.MudBlazor.Server/ApplicationExtensions.cs
@@ -0,0 +1,21 @@
+using JetBrains.Annotations;
+using Microsoft.AspNetCore.Builder;
+using Sitko.Core.App;
+using Sitko.Core.Blazor.MudBlazorComponents;
+using Sitko.Core.Blazor.Server;
+
+namespace Sitko.Core.Blazor.MudBlazor.Server;
+
+[PublicAPI]
+public static class ApplicationExtensions
+{
+ public static WebApplicationBuilder AddMudBlazorServer(this WebApplicationBuilder webApplicationBuilder)
+ {
+ webApplicationBuilder.AddSitkoCore().AddMudBlazorServer();
+ return webApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder
+ AddMudBlazorServer(this SitkoCoreApplicationBuilder webApplicationBuilder) =>
+ webApplicationBuilder.AddBlazorServer().AddMudBlazor();
+}
diff --git a/src/Sitko.Core.Blazor.MudBlazor.Server/MudBlazorApplication.cs b/src/Sitko.Core.Blazor.MudBlazor.Server/MudBlazorApplication.cs
deleted file mode 100644
index a8d1b8a35..000000000
--- a/src/Sitko.Core.Blazor.MudBlazor.Server/MudBlazorApplication.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Sitko.Core.Blazor.MudBlazorComponents;
-using Sitko.Core.Blazor.Server;
-
-namespace Sitko.Core.Blazor.MudBlazor.Server;
-
-public class MudBlazorApplication : BlazorApplication where TStartup : MudBlazorStartup
-{
- public MudBlazorApplication(string[] args) : base(args) => this.AddMudBlazor();
-}
diff --git a/src/Sitko.Core.Blazor.MudBlazor/ApplicationExtensions.cs b/src/Sitko.Core.Blazor.MudBlazor/ApplicationExtensions.cs
index 3bee91e29..a5694728d 100644
--- a/src/Sitko.Core.Blazor.MudBlazor/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Blazor.MudBlazor/ApplicationExtensions.cs
@@ -1,4 +1,6 @@
-using Microsoft.Extensions.DependencyInjection;
+using JetBrains.Annotations;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using MudBlazor.Services;
using Sitko.Core.App;
using Sitko.Core.App.Localization;
@@ -6,10 +8,17 @@
namespace Sitko.Core.Blazor.MudBlazorComponents;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddMudBlazor(this Application application) =>
- application.ConfigureServices(services =>
+ public static IHostApplicationBuilder AddMudBlazor(this IHostApplicationBuilder hostApplicationBuilder)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddMudBlazor();
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddMudBlazor(this SitkoCoreApplicationBuilder applicationBuilder) =>
+ applicationBuilder.ConfigureServices(services =>
{
services.AddMudServices();
services.AddScoped, MudLayoutManager>();
diff --git a/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BaseLayoutComponent.cs b/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BaseLayoutComponent.cs
index 2661300c6..20554d254 100644
--- a/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BaseLayoutComponent.cs
+++ b/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BaseLayoutComponent.cs
@@ -24,7 +24,7 @@ protected virtual MudTheme Theme
case AppTheme.Dark:
return new MudTheme
{
- Palette = new Palette
+ Palette = new PaletteDark
{
Primary = "#527cfa",
Secondary = "#b20942",
diff --git a/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BasicMudLayout.razor b/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BasicMudLayout.razor
index b01c4c7af..3cbd37eb5 100644
--- a/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BasicMudLayout.razor
+++ b/src/Sitko.Core.Blazor.MudBlazor/Components/Layout/BasicMudLayout.razor
@@ -14,10 +14,10 @@
- @Application.Name
+ @ApplicationContext.Name
- @Application.Name
+ @ApplicationContext.Name
diff --git a/src/Sitko.Core.Blazor.Server/BlazorApplication.cs b/src/Sitko.Core.Blazor.Server/BlazorApplication.cs
index daed60518..a760d5ddf 100644
--- a/src/Sitko.Core.Blazor.Server/BlazorApplication.cs
+++ b/src/Sitko.Core.Blazor.Server/BlazorApplication.cs
@@ -1,16 +1,27 @@
-using Sitko.Blazor.ScriptInjector;
+using JetBrains.Annotations;
+using Microsoft.AspNetCore.Builder;
+using Sitko.Blazor.ScriptInjector;
+using Sitko.Core.App;
using Sitko.Core.App.Web;
namespace Sitko.Core.Blazor.Server;
-public abstract class BlazorApplication : WebApplication where TStartup : BlazorStartup
+[PublicAPI]
+public static class ApplicationExtensions
{
- protected BlazorApplication(string[] args) : base(args)
+ public static WebApplicationBuilder AddBlazorServer(this WebApplicationBuilder webApplicationBuilder)
{
- this.AddPersistentState();
- ConfigureServices(collection =>
+ webApplicationBuilder.AddSitkoCore().AddBlazorServer();
+ return webApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddBlazorServer(this SitkoCoreApplicationBuilder webApplicationBuilder)
+ {
+ webApplicationBuilder.AddPersistentState();
+ webApplicationBuilder.ConfigureServices(collection =>
{
collection.AddScriptInjector();
});
+ return webApplicationBuilder;
}
}
diff --git a/src/Sitko.Core.Blazor.Wasm/WasmApplication.cs b/src/Sitko.Core.Blazor.Wasm/WasmApplication.cs
index 0ca09c30d..e033113f1 100644
--- a/src/Sitko.Core.Blazor.Wasm/WasmApplication.cs
+++ b/src/Sitko.Core.Blazor.Wasm/WasmApplication.cs
@@ -1,149 +1,150 @@
-using System.Globalization;
-using JetBrains.Annotations;
-using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.JSInterop;
-using Serilog;
-using Sitko.Blazor.ScriptInjector;
-using Sitko.Core.App;
-using Sitko.Core.App.Localization;
-using Sitko.Core.App.Logging;
-using Sitko.Core.Blazor.Components;
-using Sitko.Core.Blazor.Forms;
-
-namespace Sitko.Core.Blazor.Wasm;
-
-public abstract class WasmApplication : Application
-{
- private WebAssemblyHost? appHost;
-
- protected WasmApplication(string[] args) : base(args) => this.AddPersistentState();
-
- protected WebAssemblyHost CreateAppHost(Action? configure = null)
- {
- LogInternal("Create app host start");
-
- if (appHost is not null)
- {
- LogInternal("App host is already built");
-
- return appHost;
- }
-
- LogInternal("Configure host builder");
-
- var hostBuilder = ConfigureHostBuilder(configure);
-
- LogInternal("Build host");
- var newHost = hostBuilder.Build();
-
- appHost = newHost;
- LogInternal("Create app host done");
- return appHost;
- }
-
- private WebAssemblyHostBuilder CreateHostBuilder(string[] hostBuilderArgs)
- {
- var builder = WebAssemblyHostBuilder.CreateDefault(hostBuilderArgs);
- ConfigureHostBuilder(builder);
- return builder;
- }
-
- protected abstract void ConfigureHostBuilder(WebAssemblyHostBuilder builder);
-
- private WebAssemblyHostBuilder ConfigureHostBuilder(Action? configure = null)
- {
- LogInternal("Configure host builder start");
- LogInternal("Init application");
- InitApplication();
-
- LogInternal("Create host builder");
- var hostBuilder = CreateHostBuilder(Args);
- var tmpHost = hostBuilder.Build();
- var applicationContext = GetContext(hostBuilder.HostEnvironment, hostBuilder.Configuration);
- var enabledModuleRegistrations = GetEnabledModuleRegistrations(applicationContext);
- // App configuration
- ConfigureConfiguration(applicationContext, hostBuilder.Configuration);
- // App services
- RegisterApplicationServices(applicationContext, hostBuilder.Services);
- hostBuilder.Services.AddScriptInjector();
- hostBuilder.Services.AddScoped();
- hostBuilder.Services.Configure(options =>
- {
- options.AddDefaultResource(typeof(BaseForm));
- });
- // Logging
- LogInternal("Configure logging");
- LoggingExtensions.ConfigureSerilog(applicationContext, hostBuilder.Logging,
- configuration =>
- {
- configuration = configuration.WriteTo.BrowserConsole(
- outputTemplate: applicationContext.Options.ConsoleLogFormat,
- formatProvider: CultureInfo.InvariantCulture,
- jsRuntime: tmpHost.Services.GetRequiredService());
-
- return ConfigureLogging(applicationContext, configuration);
- });
-
- // Host builder via modules
- LogInternal("Configure host builder in modules");
- foreach (var configurationModule in enabledModuleRegistrations
- .Select(module => module.GetInstance())
- // ReSharper disable once SuspiciousTypeConversion.Global
- .OfType())
- {
- configurationModule.ConfigureHostBuilder(applicationContext, hostBuilder);
- }
-
- // Host builder via action
- LogInternal("Configure host builder");
- configure?.Invoke(hostBuilder);
- LogInternal("Create host builder done");
- return hostBuilder;
- }
-
- protected override void LogInternal(string message) => Log.Logger.Debug("Internal: {Message}", message);
-
- private async Task GetOrCreateHostAsync(Action? configure = null)
- {
- if (appHost is not null)
- {
- return appHost;
- }
-
- appHost = CreateAppHost(configure);
-
- await InitAsync(appHost.Services);
-
- return appHost;
- }
-
- protected override async Task DoRunAsync()
- {
- var currentHost = await GetOrCreateHostAsync();
- await currentHost.RunAsync();
- }
-
- protected override async Task BuildAppContextAsync()
- {
- var currentHost = await GetOrCreateHostAsync();
- return GetContext(currentHost.Services);
- }
-
- public override Task StopAsync() => throw new NotImplementedException();
- protected override bool CanAddModule() => true;
-
- protected override IApplicationContext GetContext() => appHost is not null
- ? GetContext(appHost.Services)
- : throw new InvalidOperationException("App host is not built yet");
-
- [PublicAPI]
- protected IApplicationContext GetContext(IWebAssemblyHostEnvironment environment,
- IConfiguration configuration) =>
- new WasmApplicationContext(this, configuration, environment);
-
- protected override IApplicationContext GetContext(IServiceProvider serviceProvider) => GetContext(
- serviceProvider.GetRequiredService(),
- serviceProvider.GetRequiredService());
-}
+// TODO: DELETE
+// using System.Globalization;
+// using JetBrains.Annotations;
+// using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+// using Microsoft.Extensions.Configuration;
+// using Microsoft.Extensions.DependencyInjection;
+// using Microsoft.JSInterop;
+// using Serilog;
+// using Sitko.Blazor.ScriptInjector;
+// using Sitko.Core.App;
+// using Sitko.Core.App.Localization;
+// using Sitko.Core.App.Logging;
+// using Sitko.Core.Blazor.Components;
+// using Sitko.Core.Blazor.Forms;
+//
+// namespace Sitko.Core.Blazor.Wasm;
+//
+// public abstract class WasmApplication : Application
+// {
+// private WebAssemblyHost? appHost;
+//
+// protected WasmApplication(string[] args) : base(args) => this.AddPersistentState();
+//
+// protected WebAssemblyHost CreateAppHost(Action? configure = null)
+// {
+// LogInternal("Create app host start");
+//
+// if (appHost is not null)
+// {
+// LogInternal("App host is already built");
+//
+// return appHost;
+// }
+//
+// LogInternal("Configure host builder");
+//
+// var hostBuilder = ConfigureHostBuilder(configure);
+//
+// LogInternal("Build host");
+// var newHost = hostBuilder.Build();
+//
+// appHost = newHost;
+// LogInternal("Create app host done");
+// return appHost;
+// }
+//
+// private WebAssemblyHostBuilder CreateHostBuilder(string[] hostBuilderArgs)
+// {
+// var builder = WebAssemblyHostBuilder.CreateDefault(hostBuilderArgs);
+// ConfigureHostBuilder(builder);
+// return builder;
+// }
+//
+// protected abstract void ConfigureHostBuilder(WebAssemblyHostBuilder builder);
+//
+// private WebAssemblyHostBuilder ConfigureHostBuilder(Action? configure = null)
+// {
+// LogInternal("Configure host builder start");
+// LogInternal("Init application");
+// InitApplication();
+//
+// LogInternal("Create host builder");
+// var hostBuilder = CreateHostBuilder(Args);
+// var tmpHost = hostBuilder.Build();
+// var applicationContext = GetContext(hostBuilder.HostEnvironment, hostBuilder.Configuration);
+// var enabledModuleRegistrations = GetEnabledModuleRegistrations(applicationContext);
+// // App configuration
+// ConfigureConfiguration(applicationContext, hostBuilder.Configuration);
+// // App services
+// RegisterApplicationServices(applicationContext, hostBuilder.Services);
+// hostBuilder.Services.AddScriptInjector();
+// hostBuilder.Services.AddScoped();
+// hostBuilder.Services.Configure(options =>
+// {
+// options.AddDefaultResource(typeof(BaseForm));
+// });
+// // Logging
+// LogInternal("Configure logging");
+// LoggingExtensions.ConfigureSerilog(applicationContext, hostBuilder.Logging,
+// configuration =>
+// {
+// configuration = configuration.WriteTo.BrowserConsole(
+// outputTemplate: applicationContext.Options.ConsoleLogFormat,
+// formatProvider: CultureInfo.InvariantCulture,
+// jsRuntime: tmpHost.Services.GetRequiredService());
+//
+// return ConfigureLogging(applicationContext, configuration);
+// });
+//
+// // Host builder via modules
+// LogInternal("Configure host builder in modules");
+// foreach (var configurationModule in enabledModuleRegistrations
+// .Select(module => module.GetInstance())
+// // ReSharper disable once SuspiciousTypeConversion.Global
+// .OfType())
+// {
+// configurationModule.ConfigureHostBuilder(applicationContext, hostBuilder);
+// }
+//
+// // Host builder via action
+// LogInternal("Configure host builder");
+// configure?.Invoke(hostBuilder);
+// LogInternal("Create host builder done");
+// return hostBuilder;
+// }
+//
+// protected override void LogInternal(string message) => Log.Logger.Debug("Internal: {Message}", message);
+//
+// private async Task GetOrCreateHostAsync(Action? configure = null)
+// {
+// if (appHost is not null)
+// {
+// return appHost;
+// }
+//
+// appHost = CreateAppHost(configure);
+//
+// await InitAsync(appHost.Services);
+//
+// return appHost;
+// }
+//
+// protected override async Task DoRunAsync()
+// {
+// var currentHost = await GetOrCreateHostAsync();
+// await currentHost.RunAsync();
+// }
+//
+// protected override async Task BuildAppContextAsync()
+// {
+// var currentHost = await GetOrCreateHostAsync();
+// return GetContext(currentHost.Services);
+// }
+//
+// public override Task StopAsync() => throw new NotImplementedException();
+// protected override bool CanAddModule() => true;
+//
+// protected override IApplicationContext GetContext() => appHost is not null
+// ? GetContext(appHost.Services)
+// : throw new InvalidOperationException("App host is not built yet");
+//
+// [PublicAPI]
+// protected IApplicationContext GetContext(IWebAssemblyHostEnvironment environment,
+// IConfiguration configuration) =>
+// new WasmApplicationContext(this, configuration, environment);
+//
+// protected override IApplicationContext GetContext(IServiceProvider serviceProvider) => GetContext(
+// serviceProvider.GetRequiredService(),
+// serviceProvider.GetRequiredService());
+// }
diff --git a/src/Sitko.Core.Blazor.Wasm/WasmApplicationContext.cs b/src/Sitko.Core.Blazor.Wasm/WasmApplicationContext.cs
index a0ff0e3f3..1b357e4b4 100644
--- a/src/Sitko.Core.Blazor.Wasm/WasmApplicationContext.cs
+++ b/src/Sitko.Core.Blazor.Wasm/WasmApplicationContext.cs
@@ -1,21 +1,22 @@
-using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
-using Microsoft.Extensions.Configuration;
-using Sitko.Core.App;
-
-namespace Sitko.Core.Blazor.Wasm;
-
-public class WasmApplicationContext : BaseApplicationContext
-{
- private readonly IWebAssemblyHostEnvironment environment;
-
- public WasmApplicationContext(Application application, IConfiguration configuration,
- IWebAssemblyHostEnvironment environment)
- : base(application, configuration) =>
- this.environment = environment;
-
- public override string AspNetEnvironmentName => environment.Environment;
- public override bool IsDevelopment() => environment.IsDevelopment();
-
- public override bool IsProduction() => environment.IsProduction();
-}
-
+// TODO: DELETE
+// using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+// using Microsoft.Extensions.Configuration;
+// using Sitko.Core.App;
+//
+// namespace Sitko.Core.Blazor.Wasm;
+//
+// public class WasmApplicationContext : BaseApplicationContext
+// {
+// private readonly IWebAssemblyHostEnvironment environment;
+//
+// public WasmApplicationContext(Application application, IConfiguration configuration,
+// IWebAssemblyHostEnvironment environment)
+// : base(application, configuration) =>
+// this.environment = environment;
+//
+// public override string AspNetEnvironmentName => environment.Environment;
+// public override bool IsDevelopment() => environment.IsDevelopment();
+//
+// public override bool IsProduction() => environment.IsProduction();
+// }
+//
diff --git a/src/Sitko.Core.Blazor/ApplicationExtensions.cs b/src/Sitko.Core.Blazor/ApplicationExtensions.cs
index f6a822c67..013578070 100644
--- a/src/Sitko.Core.Blazor/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Blazor/ApplicationExtensions.cs
@@ -1,17 +1,33 @@
+using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
using Sitko.Core.Blazor.Components;
namespace Sitko.Core.Blazor;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddPersistentState(this Application application)
+ public static IHostApplicationBuilder AddPersistentState(
+ this IHostApplicationBuilder hostApplicationBuilder)
+ where TCompressor : class, IStateCompressor
+ where TComponentState : class, ICompressedPersistentComponentState
+ {
+ hostApplicationBuilder.AddSitkoCore().AddPersistentState();
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddPersistentState(this IHostApplicationBuilder hostApplicationBuilder) =>
+ AddPersistentState(hostApplicationBuilder);
+
+ public static SitkoCoreApplicationBuilder AddPersistentState(
+ this SitkoCoreApplicationBuilder applicationBuilder)
where TCompressor : class, IStateCompressor
where TComponentState : class, ICompressedPersistentComponentState =>
- application.ConfigureServices(collection => collection.AddScoped()
+ applicationBuilder.ConfigureServices(collection => collection.AddScoped()
.AddScoped());
- public static Application AddPersistentState(this Application application) =>
- AddPersistentState(application);
+ public static SitkoCoreApplicationBuilder AddPersistentState(this SitkoCoreApplicationBuilder applicationBuilder) =>
+ AddPersistentState(applicationBuilder);
}
diff --git a/src/Sitko.Core.Blazor/Layout/BaseLayoutComponent.cs b/src/Sitko.Core.Blazor/Layout/BaseLayoutComponent.cs
index 868d54796..96a540264 100644
--- a/src/Sitko.Core.Blazor/Layout/BaseLayoutComponent.cs
+++ b/src/Sitko.Core.Blazor/Layout/BaseLayoutComponent.cs
@@ -12,7 +12,7 @@ public abstract class BaseLayoutComponent : BaseCom
protected string Description { get; set; } = "";
protected virtual string PageTitleSeparator => "/";
[Inject] protected ILayoutManager LayoutManager { get; set; } = null!;
- [Inject] protected IApplication Application { get; set; } = null!;
+ [Inject] protected IApplicationContext ApplicationContext { get; set; } = null!;
[EditorRequired]
[Parameter] public RenderFragment ChildContent { get; set; } = null!;
@@ -27,7 +27,7 @@ private void LayoutDataChanged(TLayoutData layoutData)
{
Title = layoutData.Title;
Description = layoutData.Description;
- var prefix = $" {PageTitleSeparator} {Application.Name}";
+ var prefix = $" {PageTitleSeparator} {ApplicationContext.Name}";
if (!string.IsNullOrEmpty(LayoutManager.LayoutOptions.PageTitlePostfix))
{
prefix = LayoutManager.LayoutOptions.PageTitlePostfix;
diff --git a/src/Sitko.Core.Configuration.Vault/ApplicationExtensions.cs b/src/Sitko.Core.Configuration.Vault/ApplicationExtensions.cs
index 59c9e63b1..3143b0f26 100644
--- a/src/Sitko.Core.Configuration.Vault/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Configuration.Vault/ApplicationExtensions.cs
@@ -1,18 +1,35 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Configuration.Vault;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddVaultConfiguration(this Application application,
+ public static IHostApplicationBuilder AddVaultConfiguration(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddVaultConfiguration(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddVaultConfiguration(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddVaultConfiguration(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddVaultConfiguration(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure,
string? optionsKey = null) =>
- application.AddModule(configure,
+ applicationBuilder.AddModule(configure,
optionsKey);
- public static Application AddVaultConfiguration(this Application application,
+ public static SitkoCoreApplicationBuilder AddVaultConfiguration(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application.AddModule(configure,
+ applicationBuilder.AddModule(configure,
optionsKey);
}
-
diff --git a/src/Sitko.Core.Consul.Web/ApplicationExtensions.cs b/src/Sitko.Core.Consul.Web/ApplicationExtensions.cs
index 4a6f271b1..93b2adacd 100644
--- a/src/Sitko.Core.Consul.Web/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Consul.Web/ApplicationExtensions.cs
@@ -1,17 +1,35 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Consul.Web;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddConsulWeb(this Application application,
+ public static IHostApplicationBuilder AddConsulWeb(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddConsulWeb(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddConsulWeb(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null,
+ string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddConsulWeb(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddConsulWeb(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure,
string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddConsulWeb(this Application application,
+ public static SitkoCoreApplicationBuilder AddConsulWeb(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null,
string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.Consul/ApplicationExtensions.cs b/src/Sitko.Core.Consul/ApplicationExtensions.cs
index 8fec6f42f..cf851a6a6 100644
--- a/src/Sitko.Core.Consul/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Consul/ApplicationExtensions.cs
@@ -1,15 +1,31 @@
-using Sitko.Core.App;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Hosting;
+using Sitko.Core.App;
namespace Sitko.Core.Consul;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddConsul(this Application application,
+ public static IHostApplicationBuilder AddConsul(this IHostApplicationBuilder hostApplicationBuilder,
+ Action configure, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddConsul(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddConsul(this IHostApplicationBuilder hostApplicationBuilder,
+ Action? configure = null, string? optionsKey = null)
+ {
+ hostApplicationBuilder.AddSitkoCore().AddConsul(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddConsul(this SitkoCoreApplicationBuilder applicationBuilder,
Action configure, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
- public static Application AddConsul(this Application application,
+ public static SitkoCoreApplicationBuilder AddConsul(this SitkoCoreApplicationBuilder applicationBuilder,
Action? configure = null, string? optionsKey = null) =>
- application.AddModule(configure, optionsKey);
+ applicationBuilder.AddModule(configure, optionsKey);
}
-
diff --git a/src/Sitko.Core.Db.InMemory/ApplicationExtensions.cs b/src/Sitko.Core.Db.InMemory/ApplicationExtensions.cs
index 3fb636079..9ecf757b7 100644
--- a/src/Sitko.Core.Db.InMemory/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Db.InMemory/ApplicationExtensions.cs
@@ -1,24 +1,48 @@
-using Microsoft.EntityFrameworkCore;
+using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
namespace Sitko.Core.Db.InMemory;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddInMemoryDatabase(this Application application,
+ public static IHostApplicationBuilder AddInMemoryDatabase(
+ this IHostApplicationBuilder hostApplicationBuilder,
+ Action> configure,
+ string? optionsKey = null)
+ where TDbContext : DbContext
+ {
+ hostApplicationBuilder.AddSitkoCore().AddInMemoryDatabase(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static IHostApplicationBuilder AddInMemoryDatabase(
+ this IHostApplicationBuilder hostApplicationBuilder,
+ Action>? configure = null,
+ string? optionsKey = null)
+ where TDbContext : DbContext
+ {
+ hostApplicationBuilder.AddSitkoCore().AddInMemoryDatabase(configure, optionsKey);
+ return hostApplicationBuilder;
+ }
+
+ public static SitkoCoreApplicationBuilder AddInMemoryDatabase(
+ this SitkoCoreApplicationBuilder applicationBuilder,
Action> configure,
string? optionsKey = null)
where TDbContext : DbContext =>
- application
+ applicationBuilder
.AddModule, InMemoryDatabaseModuleOptions>(configure,
optionsKey);
- public static Application AddInMemoryDatabase(this Application application,
+ public static SitkoCoreApplicationBuilder AddInMemoryDatabase(
+ this SitkoCoreApplicationBuilder applicationBuilder,
Action>? configure = null,
string? optionsKey = null)
where TDbContext : DbContext =>
- application
+ applicationBuilder
.AddModule, InMemoryDatabaseModuleOptions>(configure,
optionsKey);
}
-
diff --git a/src/Sitko.Core.Db.Postgres/ApplicationExtensions.cs b/src/Sitko.Core.Db.Postgres/ApplicationExtensions.cs
index 5bc5ea0ac..bc06dd40c 100644
--- a/src/Sitko.Core.Db.Postgres/ApplicationExtensions.cs
+++ b/src/Sitko.Core.Db.Postgres/ApplicationExtensions.cs
@@ -1,24 +1,48 @@
-using Microsoft.EntityFrameworkCore;
+using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Hosting;
using Sitko.Core.App;
namespace Sitko.Core.Db.Postgres;
+[PublicAPI]
public static class ApplicationExtensions
{
- public static Application AddPostgresDatabase(this Application application,
+ public static IHostApplicationBuilder AddPostgresDatabase