2024-04-27 00:25:32 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using OliverBooth.Data.Web;
|
2024-05-05 02:18:20 +01:00
|
|
|
using OliverBooth.Extensions.Markdig.Markdown.Template;
|
2024-04-27 00:25:32 +01:00
|
|
|
|
|
|
|
namespace OliverBooth.Markdown.Template;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a custom renderer which overrides the default behaviour of the template engine.
|
|
|
|
/// </summary>
|
|
|
|
internal abstract class CustomTemplateRenderer
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="CustomTemplateRenderer" /> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="serviceProvider">The service provider.</param>
|
|
|
|
protected CustomTemplateRenderer(IServiceProvider serviceProvider)
|
|
|
|
{
|
|
|
|
DbContextFactory = serviceProvider.GetRequiredService<IDbContextFactory<WebContext>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the <see cref="WebContext" /> factory that was injected into this instance.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>An <see cref="IDbContextFactory{TContext}" /> for <see cref="WebContext" />.</value>
|
|
|
|
protected IDbContextFactory<WebContext> DbContextFactory { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Renders the specified template.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="template">The template to render.</param>
|
|
|
|
/// <returns>The rendered result of the template.</returns>
|
|
|
|
public abstract string Render(TemplateInline template);
|
|
|
|
}
|