YaeBlog/YaeBlog.Core/Extensions/BlogApplicationExtension.cs
2024-01-25 17:33:46 +08:00

36 lines
1.2 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using YaeBlog.Core.Abstractions;
using YaeBlog.Core.Builder;
using YaeBlog.Core.Processors;
using YaeBlog.Core.Services;
namespace YaeBlog.Core.Extensions;
public static class BlogApplicationExtension
{
internal static void ConfigureDefaultBlogApplication(this BlogApplication application)
{
application.UsePostRenderProcessor<ImagePostRenderProcessor>();
}
public static void UsePreRenderProcessor<T>(this BlogApplication application)
where T : IPreRenderProcessor
{
RendererService rendererService =
application.Services.GetRequiredService<RendererService>();
T preRenderProcessor =
application.Services.GetRequiredService<T>();
rendererService.AddPreRenderProcessor(preRenderProcessor);
}
public static void UsePostRenderProcessor<T>(this BlogApplication application)
where T : IPostRenderProcessor
{
RendererService rendererService =
application.Services.GetRequiredService<RendererService>();
T postRenderProcessor =
application.Services.GetRequiredService<T>();
rendererService.AddPostRenderProcessor(postRenderProcessor);
}
}