mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-03-31 05:12:35 -04:00
28 lines
831 B
C#
28 lines
831 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using FileManager.NamingTemplate;
|
|
|
|
namespace LibationFileManager.Templates;
|
|
|
|
public record SeriesDto(string? Name, string? Number, string AudibleSeriesId) : IFormattable
|
|
{
|
|
public SeriesOrder Order { get; } = SeriesOrder.Parse(Number);
|
|
|
|
public static readonly Dictionary<string, Func<SeriesDto, object?>> FormatReplacements = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
{ "#", dto => dto.Order },
|
|
{ "N", dto => dto.Name },
|
|
{ "ID", dto => dto.AudibleSeriesId }
|
|
};
|
|
|
|
public override string? ToString() => Name?.Trim();
|
|
|
|
public string ToString(string? format, IFormatProvider? provider)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(format))
|
|
return ToString() ?? string.Empty;
|
|
|
|
return CommonFormatters.TemplateStringFormatter(this, format, provider, FormatReplacements).Trim();
|
|
}
|
|
}
|