Files
SabreTools/SabreTools.DatItems/Formats/Slot.cs

87 lines
2.3 KiB
C#
Raw Normal View History

2020-09-01 16:21:55 -07:00
using System.Collections.Generic;
using System.Linq;
2020-09-07 22:00:02 -07:00
using System.Xml.Serialization;
2020-09-01 16:21:55 -07:00
using Newtonsoft.Json;
2022-11-03 12:22:17 -07:00
using SabreTools.Core;
2020-09-01 16:21:55 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-01 16:21:55 -07:00
{
/// <summary>
/// Represents which Slot(s) is associated with a set
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("slot"), XmlRoot("slot")]
2020-09-01 16:21:55 -07:00
public class Slot : DatItem
{
#region Fields
2020-09-02 12:19:12 -07:00
/// <summary>
/// Name of the item
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadString(Models.Internal.Slot.NameKey);
set => _internal[Models.Internal.Slot.NameKey] = value;
}
2020-09-02 12:19:12 -07:00
2020-09-01 16:21:55 -07:00
/// <summary>
/// Slot options associated with the slot
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("slotoptions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("slotoptions")]
public List<SlotOption>? SlotOptions
{
2023-08-14 22:33:05 -04:00
get => _internal.Read<SlotOption[]>(Models.Internal.Slot.SlotOptionKey)?.ToList();
set => _internal[Models.Internal.Slot.SlotOptionKey] = value?.ToArray();
}
2020-09-01 16:21:55 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool SlotOptionsSpecified { get { return SlotOptions != null && SlotOptions.Count > 0; } }
2020-09-01 16:21:55 -07:00
#endregion
#region Accessors
/// <inheritdoc/>
public override string? GetName() => Name;
2020-09-02 12:19:12 -07:00
/// <inheritdoc/>
public override void SetName(string? name) => Name = name;
2020-09-01 16:21:55 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Slot object
/// </summary>
public Slot()
{
2023-08-14 22:33:05 -04:00
_internal = new Models.Internal.Slot();
2020-09-01 16:21:55 -07:00
Name = string.Empty;
ItemType = ItemType.Slot;
}
#endregion
#region Cloning Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
2020-09-01 16:21:55 -07:00
public override object Clone()
{
return new Slot()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Source = this.Source?.Clone() as Source,
2020-09-01 16:21:55 -07:00
Remove = this.Remove,
2023-08-14 22:33:05 -04:00
_internal = this._internal?.Clone() as Models.Internal.Slot ?? new Models.Internal.Slot(),
2020-09-01 16:21:55 -07:00
};
}
#endregion
}
}