You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/TrashLib/Services/CustomFormat/Models/ProcessedCustomFormatData.cs

34 lines
1.0 KiB

using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Linq;
using TrashLib.Services.CustomFormat.Models.Cache;
namespace TrashLib.Services.CustomFormat.Models;
public class ProcessedCustomFormatData
{
private readonly CustomFormatData _data;
public ProcessedCustomFormatData(CustomFormatData data)
{
_data = data;
Json = _data.Json;
}
public string Name => _data.Name;
public string TrashId => _data.TrashId;
public int? Score => _data.Score;
public JObject Json { get; set; }
public TrashIdMapping? CacheEntry { get; set; }
public void SetCache(int customFormatId)
{
CacheEntry ??= new TrashIdMapping(TrashId);
CacheEntry.CustomFormatId = customFormatId;
}
[SuppressMessage("Microsoft.Design", "CA1024", Justification = "Method throws an exception")]
public int GetCustomFormatId()
=> CacheEntry?.CustomFormatId ??
throw new InvalidOperationException("CacheEntry must exist to obtain custom format ID");
}