2024-01-23 20:37:41 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using YaeBlog.Core.Abstractions;
|
2024-01-17 13:20:32 +08:00
|
|
|
|
using YaeBlog.Core.Builder;
|
2024-01-25 15:55:09 +08:00
|
|
|
|
using YaeBlog.Core.Processors;
|
2024-01-17 13:20:32 +08:00
|
|
|
|
using YaeBlog.Core.Services;
|
|
|
|
|
|
|
|
|
|
namespace YaeBlog.Core.Extensions;
|
|
|
|
|
|
2024-01-20 17:09:01 +08:00
|
|
|
|
public static class BlogApplicationExtension
|
2024-01-17 13:20:32 +08:00
|
|
|
|
{
|
2024-01-25 11:41:54 +08:00
|
|
|
|
internal static void ConfigureDefaultBlogApplication(this BlogApplication application)
|
|
|
|
|
{
|
2024-01-25 15:55:09 +08:00
|
|
|
|
//application.UsePostRenderProcessor<ImagePostRenderProcessor>();
|
2024-01-25 11:41:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-23 20:37:41 +08:00
|
|
|
|
public static void UsePreRenderProcessor<T>(this BlogApplication application)
|
|
|
|
|
where T : IPreRenderProcessor
|
2024-01-17 13:20:32 +08:00
|
|
|
|
{
|
2024-01-23 20:37:41 +08:00
|
|
|
|
RendererService rendererService =
|
|
|
|
|
application.Services.GetRequiredService<RendererService>();
|
|
|
|
|
T preRenderProcessor =
|
|
|
|
|
application.Services.GetRequiredService<T>();
|
|
|
|
|
rendererService.AddPreRenderProcessor(preRenderProcessor);
|
2024-01-20 12:26:30 +08:00
|
|
|
|
}
|
2024-01-17 13:20:32 +08:00
|
|
|
|
|
2024-01-23 20:37:41 +08:00
|
|
|
|
public static void UsePostRenderProcessor<T>(this BlogApplication application)
|
|
|
|
|
where T : IPostRenderProcessor
|
2024-01-20 12:26:30 +08:00
|
|
|
|
{
|
2024-01-23 20:37:41 +08:00
|
|
|
|
RendererService rendererService =
|
|
|
|
|
application.Services.GetRequiredService<RendererService>();
|
|
|
|
|
T postRenderProcessor =
|
|
|
|
|
application.Services.GetRequiredService<T>();
|
|
|
|
|
rendererService.AddPostRenderProcessor(postRenderProcessor);
|
2024-01-17 13:20:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|