Move more to the DatItem base class

This commit is contained in:
Matt Nadareski
2023-08-14 22:33:05 -04:00
parent 6adbe601a2
commit ed1f809065
41 changed files with 708 additions and 1310 deletions

View File

@@ -18,16 +18,10 @@ namespace SabreTools.DatItems.Formats
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
get => _sample.ReadString(Models.Internal.Sample.NameKey);
set => _sample[Models.Internal.Sample.NameKey] = value;
get => _internal.ReadString(Models.Internal.Sample.NameKey);
set => _internal[Models.Internal.Sample.NameKey] = value;
}
/// <summary>
/// Internal Sample model
/// </summary>
[JsonIgnore]
private Models.Internal.Sample _sample = new();
#endregion
#region Accessors
@@ -47,6 +41,7 @@ namespace SabreTools.DatItems.Formats
/// </summary>
public Sample()
{
_internal = new Models.Internal.Sample();
Name = string.Empty;
ItemType = ItemType.Sample;
}
@@ -67,25 +62,10 @@ namespace SabreTools.DatItems.Formats
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
_sample = this._sample?.Clone() as Models.Internal.Sample ?? new Models.Internal.Sample(),
_internal = this._internal?.Clone() as Models.Internal.Sample ?? new Models.Internal.Sample(),
};
}
#endregion
#region Comparision Methods
/// <inheritdoc/>
public override bool Equals(DatItem? other)
{
// If we don't have a Sample, return false
if (ItemType != other?.ItemType || other is not Sample otherInternal)
return false;
// Compare the internal models
return _sample.EqualTo(otherInternal._sample);
}
#endregion
}
}