mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
The map is curiously BLANK
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -7,84 +8,26 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
/// Represents a blank set from an input DAT
|
||||
/// </summary>
|
||||
[JsonObject("blank"), XmlRoot("blank")]
|
||||
public sealed class Blank : DatItem
|
||||
public sealed class Blank : DatItem<Data.Models.Metadata.Blank>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <inheritdoc>/>
|
||||
public override Data.Models.Metadata.ItemType ItemType => Data.Models.Metadata.ItemType.Blank;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Blank object
|
||||
/// </summary>
|
||||
public Blank() { }
|
||||
public Blank() : base() { }
|
||||
|
||||
public Blank(Data.Models.Metadata.Blank item) : base(item) { }
|
||||
|
||||
public Blank(Data.Models.Metadata.Blank item, Machine machine, Source source) : this(item)
|
||||
{
|
||||
Write<Source?>(SourceKey, source);
|
||||
CopyMachineInformation(machine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object Clone()
|
||||
{
|
||||
var blank = new Blank();
|
||||
blank.Write(MachineKey, GetMachine());
|
||||
blank.Write(RemoveKey, ReadBool(RemoveKey));
|
||||
blank.Write<Source?>(SourceKey, Read<Source?>(SourceKey));
|
||||
|
||||
return blank;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(ModelBackedItem? other)
|
||||
{
|
||||
// If other is null
|
||||
if (other is 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<Data.Models.Metadata.DatItem>? other)
|
||||
{
|
||||
// If other is null
|
||||
if (other is 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(DatItem? other)
|
||||
{
|
||||
// If we don't have a blank, return false
|
||||
if (ItemType != other?.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a Blank
|
||||
Blank? newOther = other as Blank;
|
||||
|
||||
// If the machine information matches
|
||||
return GetMachine() == newOther!.GetMachine();
|
||||
}
|
||||
public override object Clone() => new Blank(_internal.Clone() as Data.Models.Metadata.Blank ?? []);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user