refact: Fully refactor the conceptional structure and functional behaviour.

This commit is contained in:
2024-06-21 22:59:30 +08:00
parent 257f5d94ee
commit 2efe2fd5cd
64 changed files with 307 additions and 574 deletions

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using YaeBlog.Core.Abstractions;
using YaeBlog.Core.Processors;
using YaeBlog.Core.Services;
namespace YaeBlog.Core.Extensions;
public static class WebApplicationExtensions
{
public static WebApplication UseMiddleRenderProcessors(this WebApplication application)
{
application.UsePostRenderProcessor<ImagePostRenderProcessor>();
return application;
}
private static void UsePreRenderProcessor<T>(this WebApplication application) where T : IPreRenderProcessor
{
RendererService rendererService = application.Services.GetRequiredService<RendererService>();
T preRenderProcessor = application.Services.GetRequiredService<T>();
rendererService.AddPreRenderProcessor(preRenderProcessor);
}
private static void UsePostRenderProcessor<T>(this WebApplication application) where T : IPostRenderProcessor
{
RendererService rendererService = application.Services.GetRequiredService<RendererService>();
T postRenderProcessor = application.Services.GetRequiredService<T>();
rendererService.AddPostRenderProcessor(postRenderProcessor);
}
}