2020-12-14 10:58:43 -08:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-03 13:20:56 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-02 22:44:54 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-02 22:44:54 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents one ListXML slotoption
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("slotoption"), XmlRoot("slotoption")]
|
2020-09-02 22:44:54 -07:00
|
|
|
|
public class SlotOption : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Slot option name
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("name"), XmlElement("name")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _slotOption.ReadString(Models.Internal.SlotOption.NameKey);
|
|
|
|
|
|
set => _slotOption[Models.Internal.SlotOption.NameKey] = value;
|
|
|
|
|
|
}
|
2020-09-02 22:44:54 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Referenced device name
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("devname"), XmlElement("devname")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? DeviceName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _slotOption.ReadString(Models.Internal.SlotOption.DevNameKey);
|
|
|
|
|
|
set => _slotOption[Models.Internal.SlotOption.DevNameKey] = value;
|
|
|
|
|
|
}
|
2020-09-02 22:44:54 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines if this slot option is default or not
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public bool? Default
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _slotOption.ReadBool(Models.Internal.SlotOption.DefaultKey);
|
|
|
|
|
|
set => _slotOption[Models.Internal.SlotOption.DefaultKey] = value;
|
|
|
|
|
|
}
|
2020-09-02 22:44:54 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Internal SlotOption model
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
private Models.Internal.SlotOption _slotOption = new();
|
|
|
|
|
|
|
2020-09-02 22:44:54 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override string? GetName() => Name;
|
2020-09-02 22:44:54 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override void SetName(string? name) => Name = name;
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-02 22:44:54 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty SlotOption object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public SlotOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = string.Empty;
|
|
|
|
|
|
ItemType = ItemType.SlotOption;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 22:44:54 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SlotOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Machine = this.Machine?.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source?.Clone() as Source,
|
2020-09-02 22:44:54 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
_slotOption = this._slotOption?.Clone() as Models.Internal.SlotOption ?? new Models.Internal.SlotOption(),
|
2020-09-02 22:44:54 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override bool Equals(DatItem? other)
|
2020-09-02 22:44:54 -07:00
|
|
|
|
{
|
2023-08-14 13:17:51 -04:00
|
|
|
|
// If we don't have a Adjuster, return false
|
|
|
|
|
|
if (ItemType != other?.ItemType || other is not SlotOption otherInternal)
|
2020-09-02 22:44:54 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
// Compare the internal models
|
|
|
|
|
|
return _slotOption.EqualTo(otherInternal._slotOption);
|
2020-09-02 22:44:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|