2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2025-01-08 11:36:43 -05:00
|
|
|
|
using SabreTools.Core;
|
2024-03-11 16:26:28 -04:00
|
|
|
|
using SabreTools.Core.Tools;
|
2020-08-23 22:23:55 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2018-01-04 00:49:04 -08:00
|
|
|
|
{
|
2019-01-08 17:40:12 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a blank set from an input DAT
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("blank"), XmlRoot("blank")]
|
2024-03-10 20:39:54 -04:00
|
|
|
|
public sealed class Blank : DatItem
|
2019-01-08 17:40:12 -08:00
|
|
|
|
{
|
2024-03-10 20:45:54 -04:00
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc>/>
|
|
|
|
|
|
protected override ItemType ItemType => ItemType.Blank;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#region Constructors
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
/// <summary>
|
2024-10-22 13:05:51 -04:00
|
|
|
|
/// Create a default, empty Blank object
|
2019-01-08 17:40:12 -08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Blank()
|
|
|
|
|
|
{
|
2024-03-10 20:45:54 -04:00
|
|
|
|
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType);
|
2019-01-08 17:40:12 -08:00
|
|
|
|
}
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#endregion
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#region Cloning Methods
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2019-01-08 17:40:12 -08:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
2024-03-10 16:49:07 -04:00
|
|
|
|
var blank = new Blank();
|
2025-05-02 16:46:20 -04:00
|
|
|
|
blank.SetFieldValue<Machine>(DatItem.MachineKey, GetMachine());
|
2024-03-11 15:46:44 -04:00
|
|
|
|
blank.SetFieldValue<bool?>(DatItem.RemoveKey, GetBoolFieldValue(DatItem.RemoveKey));
|
2024-03-10 16:49:07 -04:00
|
|
|
|
blank.SetFieldValue<Source?>(DatItem.SourceKey, GetFieldValue<Source?>(DatItem.SourceKey));
|
2024-03-11 16:26:28 -04:00
|
|
|
|
blank.SetFieldValue<string?>(Models.Metadata.DatItem.TypeKey, GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>().AsStringValue());
|
2024-03-10 16:49:07 -04:00
|
|
|
|
|
|
|
|
|
|
return blank;
|
2019-01-08 17:40:12 -08:00
|
|
|
|
}
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#endregion
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#region Comparision Methods
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2025-01-08 11:36:43 -05:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override bool Equals(ModelBackedItem? other)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If other is null
|
|
|
|
|
|
if (other == null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// If the type is mismatched
|
|
|
|
|
|
if (other is not DatItem otherItem)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Compare internal models
|
|
|
|
|
|
return Equals(otherItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override bool Equals(ModelBackedItem<Models.Metadata.DatItem>? other)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If other is null
|
|
|
|
|
|
if (other == null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// If the type is mismatched
|
|
|
|
|
|
if (other is not DatItem otherItem)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Compare internal models
|
|
|
|
|
|
return Equals(otherItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override bool Equals(DatItem? other)
|
2019-01-08 17:40:12 -08:00
|
|
|
|
{
|
|
|
|
|
|
// If we don't have a blank, return false
|
2024-03-11 16:26:28 -04:00
|
|
|
|
if (GetStringFieldValue(Models.Metadata.DatItem.TypeKey) != other?.GetStringFieldValue(Models.Metadata.DatItem.TypeKey))
|
2019-01-08 17:40:12 -08:00
|
|
|
|
return false;
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
// Otherwise, treat it as a Blank
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Blank? newOther = other as Blank;
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2025-01-08 14:43:34 -05:00
|
|
|
|
// If the machine information matches
|
2025-05-02 16:46:20 -04:00
|
|
|
|
return GetMachine() == newOther!.GetMachine();
|
2019-01-08 17:40:12 -08:00
|
|
|
|
}
|
2018-01-04 00:49:04 -08:00
|
|
|
|
|
2019-01-08 17:40:12 -08:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
2018-01-04 00:49:04 -08:00
|
|
|
|
}
|