using System; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; namespace SabreTools.DatItems.Formats { /// /// Represents which Slot(s) is associated with a set /// [JsonObject("slot"), XmlRoot("slot")] public sealed class Slot : DatItem { #region Fields /// /> protected override ItemType ItemType => ItemType.Slot; /// /> protected override string? NameKey => Models.Metadata.Slot.NameKey; [JsonIgnore] public bool SlotOptionsSpecified { get { var slotOptions = GetFieldValue(Models.Metadata.Slot.SlotOptionKey); return slotOptions != null && slotOptions.Length > 0; } } #endregion #region Constructors public Slot() : base() { } public Slot(Models.Metadata.Slot item) : base(item) { // Handle subitems var slotOptions = item.ReadItemArray(Models.Metadata.Slot.SlotOptionKey); if (slotOptions != null) { SlotOption[] slotOptionItems = Array.ConvertAll(slotOptions, slotOption => new SlotOption(slotOption)); SetFieldValue(Models.Metadata.Slot.SlotOptionKey, slotOptionItems); } } #endregion #region Cloning Methods /// public override Models.Metadata.Slot GetInternalClone() { var slotItem = base.GetInternalClone(); var slotOptions = GetFieldValue(Models.Metadata.Slot.SlotOptionKey); if (slotOptions != null) { Models.Metadata.SlotOption[] slotOptionItems = Array.ConvertAll(slotOptions, slotOption => slotOption.GetInternalClone()); slotItem[Models.Metadata.Slot.SlotOptionKey] = slotOptionItems; } return slotItem; } #endregion } }