YaeBlog/YaeBlog.Core/Extensions/BlogApplicationExtension.cs

36 lines
1.2 KiB
C#
Raw Normal View History

using Microsoft.Extensions.DependencyInjection;
using YaeBlog.Core.Abstractions;
2024-01-17 13:20:32 +08:00
using YaeBlog.Core.Builder;
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
{
internal static void ConfigureDefaultBlogApplication(this BlogApplication application)
{
//application.UsePostRenderProcessor<ImagePostRenderProcessor>();
}
public static void UsePreRenderProcessor<T>(this BlogApplication application)
where T : IPreRenderProcessor
2024-01-17 13:20:32 +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
public static void UsePostRenderProcessor<T>(this BlogApplication application)
where T : IPostRenderProcessor
2024-01-20 12:26:30 +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
}
}