refactor: 支持设置多个WebApplicationBuilder和WebApplication配置函数

This commit is contained in:
2024-01-25 15:55:09 +08:00
parent 0f58e4ce4b
commit 154ea2b7f2
5 changed files with 33 additions and 12 deletions

View File

@@ -34,14 +34,21 @@ public static class BlogApplicationBuilderExtension
builder.Services.AddSingleton<EssayScanService>();
builder.Services.AddSingleton<RendererService>();
builder.Services.AddSingleton<EssayContentService>();
builder.Services.AddHostedService<WebApplicationHostedService>((provider)
=> new WebApplicationHostedService(builder.WebApplicationBuilderConfigurations,
builder.WebApplicationConfigurations, provider));
}
public static void ConfigureWebApplicationBuilder(this BlogApplicationBuilder builder,
Action<WebApplicationBuilder> configureWebApplicationBuilder)
{
builder.WebApplicationBuilderConfigurations.Add(configureWebApplicationBuilder);
}
public static void ConfigureWebApplication(this BlogApplicationBuilder builder,
Action<WebApplicationBuilder> configureWebApplicationBuilder,
Action<WebApplication> configureWebApplication)
{
builder.Services.AddHostedService<WebApplicationHostedService>(provider =>
new WebApplicationHostedService(configureWebApplicationBuilder,
configureWebApplication, provider));
builder.WebApplicationConfigurations.Add(configureWebApplication);
}
}

View File

@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using YaeBlog.Core.Abstractions;
using YaeBlog.Core.Builder;
using YaeBlog.Core.Processors;
using YaeBlog.Core.Services;
namespace YaeBlog.Core.Extensions;
@@ -9,7 +10,7 @@ public static class BlogApplicationExtension
{
internal static void ConfigureDefaultBlogApplication(this BlogApplication application)
{
//application.UsePostRenderProcessor<ImagePostRenderProcessor>();
}
public static void UsePreRenderProcessor<T>(this BlogApplication application)