2020-12-14 10:58:43 -08:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 16:31:23 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-02 16:31:23 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-02 16:31:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a single analog item
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("analog"), XmlRoot("analog")]
|
2020-09-02 16:31:23 -07:00
|
|
|
|
public class Analog : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Analog mask value
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("mask")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Mask
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _analog.ReadString(Models.Internal.Analog.MaskKey);
|
|
|
|
|
|
set => _analog[Models.Internal.Analog.MaskKey] = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Internal Analog model
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
private Models.Internal.Analog _analog = new();
|
2020-09-02 16:31:23 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Analog object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Analog()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = ItemType.Analog;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 16:31:23 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Analog()
|
|
|
|
|
|
{
|
|
|
|
|
|
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 16:31:23 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
_analog = this._analog?.Clone() as Models.Internal.Analog ?? new Models.Internal.Analog(),
|
2020-09-02 16:31:23 -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 16:31:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
// If we don't have a Analog, return false
|
2023-08-14 13:17:51 -04:00
|
|
|
|
if (ItemType != other?.ItemType || other is not Analog otherInternal)
|
2020-09-02 16:31:23 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
// Compare the internal models
|
|
|
|
|
|
return _analog.EqualTo(otherInternal._analog);
|
2020-09-02 16:31:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|