2023-08-15 17:04:43 +01:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
using OliverBooth.Data.Web;
|
2023-08-13 17:33:54 +01:00
|
|
|
using OliverBooth.Markdown.Template;
|
2023-08-13 13:27:44 +01:00
|
|
|
|
2023-08-13 17:33:54 +01:00
|
|
|
namespace OliverBooth.Services;
|
2023-08-13 13:27:44 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a service that renders MediaWiki-style templates.
|
|
|
|
/// </summary>
|
|
|
|
public interface ITemplateService
|
|
|
|
{
|
|
|
|
/// <summary>
|
2023-08-13 18:02:19 +01:00
|
|
|
/// Renders the specified global template with the specified arguments.
|
2023-08-13 13:27:44 +01:00
|
|
|
/// </summary>
|
2023-08-13 18:02:19 +01:00
|
|
|
/// <param name="templateInline">The global template to render.</param>
|
|
|
|
/// <returns>The rendered global template.</returns>
|
2023-08-13 13:27:44 +01:00
|
|
|
/// <exception cref="ArgumentNullException">
|
|
|
|
/// <paramref name="templateInline" /> is <see langword="null" />.
|
|
|
|
/// </exception>
|
2023-08-13 18:02:19 +01:00
|
|
|
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);
|
2023-08-15 17:04:43 +01:00
|
|
|
|
|
|
|
/// <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);
|
2023-08-13 13:27:44 +01:00
|
|
|
}
|