2026-05-04 11:55:07 +10:00
|
|
|
|
using PARR.Core.Services.Shortcodes;
|
2026-04-30 10:35:31 +10:00
|
|
|
|
using PARR.Domain.Entities;
|
2025-12-26 21:47:53 +10:00
|
|
|
|
using PARR.TemplateMatcher.Services.Interfaces;
|
2026-01-16 18:26:06 +10:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2025-12-26 21:47:53 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.TemplateMatcher.Services.Implementations;
|
|
|
|
|
|
|
|
|
|
|
|
internal class TemplateNameNormalizer : ITemplateNameNormalizer
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IShortcodesService shortcodesService;
|
|
|
|
|
|
|
|
|
|
|
|
public TemplateNameNormalizer(IShortcodesService shortcodesService)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.shortcodesService = shortcodesService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-14 16:47:27 +10:00
|
|
|
|
|
2026-01-16 18:26:06 +10:00
|
|
|
|
public async Task<string> GetNormalizedTemplateNameAsync(Template template, [CallerMemberName] string? caller = null)
|
2025-12-26 21:47:53 +10:00
|
|
|
|
{
|
2026-01-16 18:26:06 +10:00
|
|
|
|
var callerName = caller ?? "Unknown";
|
|
|
|
|
|
|
|
|
|
|
|
if (template.Job == null)
|
|
|
|
|
|
throw new ArgumentNullException(nameof(template.Job));
|
|
|
|
|
|
|
|
|
|
|
|
var rawName = await shortcodesService.ApplyShortcodesAsync(template.Job.TemplateNameMask, template, callerName);
|
2025-12-26 21:47:53 +10:00
|
|
|
|
|
|
|
|
|
|
return rawName.ToUpper();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|