oliverbooth.dev/OliverBooth.Extensions.Markdig/Services/ITemplateService.cs
Oliver Booth 6ec4103a3a
refactor: separate Markdig extensions from project
Also introduces .Common project to house common references and types
2024-05-05 02:18:20 +01:00

56 lines
2.5 KiB
C#

using System.Diagnostics.CodeAnalysis;
using OliverBooth.Common.Data.Web;
using OliverBooth.Extensions.Markdig.Markdown.Template;
namespace OliverBooth.Extensions.Markdig.Services;
/// <summary>
/// Represents a service that renders MediaWiki-style templates.
/// </summary>
public interface ITemplateService
{
/// <summary>
/// Renders the specified global template with the specified arguments.
/// </summary>
/// <param name="templateInline">The global template to render.</param>
/// <returns>The rendered global template.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="templateInline" /> is <see langword="null" />.
/// </exception>
string RenderGlobalTemplate(TemplateInline templateInline);
/// <summary>
/// Renders the specified global template with the specified arguments.
/// </summary>
/// <param name="templateInline">The global template to render.</param>
/// <param name="template">The database template object.</param>
/// <returns>The rendered global template.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="templateInline" /> is <see langword="null" />.
/// </exception>
string RenderTemplate(TemplateInline templateInline, ITemplate? template);
/// <summary>
/// Attempts to get the template with the specified name.
/// </summary>
/// <param name="name">The name of the template.</param>
/// <param name="template">
/// When this method returns, contains the template with the specified name, if the template is found;
/// otherwise, <see langword="null" />.
/// </param>
/// <returns><see langword="true" /> if the template exists; otherwise, <see langword="false" />.</returns>
bool TryGetTemplate(string name, [NotNullWhen(true)] out ITemplate? template);
/// <summary>
/// Attempts to get the template with the specified name and variant.
/// </summary>
/// <param name="name">The name of the template.</param>
/// <param name="variant">The variant of the template.</param>
/// <param name="template">
/// When this method returns, contains the template with the specified name and variant, if the template is
/// found; otherwise, <see langword="null" />.
/// </param>
/// <returns><see langword="true" /> if the template exists; otherwise, <see langword="false" />.</returns>
bool TryGetTemplate(string name, string variant, [NotNullWhen(true)] out ITemplate? template);
}