using System.Text.Json; using System.Text.Json.Serialization; namespace Inspectron.Epson.Templates.Configuration; public class TemplateConfiguration { [JsonPropertyName("assignments")] public List Assignments { get; set; } = new(); [JsonPropertyName("fallbackTemplate")] public string FallbackTemplate { get; set; } = "fallback.template"; public static TemplateConfiguration Load(string jsonPath) { var json = File.ReadAllText(jsonPath); return JsonSerializer.Deserialize(json) ?? new TemplateConfiguration(); } public static TemplateConfiguration LoadFromJson(string json) { return JsonSerializer.Deserialize(json) ?? new TemplateConfiguration(); } public IEnumerable GetAssignments() { return Assignments.Select(a => new TemplateAssignment( a.ReceiptType, a.ProfileId, a.TemplatePath)); } } public class TemplateAssignmentJson { [JsonPropertyName("receiptType")] public int ReceiptType { get; set; } [JsonPropertyName("profileId")] public string? ProfileId { get; set; } [JsonPropertyName("template")] public string TemplatePath { get; set; } = string.Empty; }