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,8 +18,8 @@ namespace SabreTools.DatItems.Formats
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
get => _confLocation.ReadString(Models.Internal.ConfLocation.NameKey);
set => _confLocation[Models.Internal.ConfLocation.NameKey] = value;
get => _internal.ReadString(Models.Internal.ConfLocation.NameKey);
set => _internal[Models.Internal.ConfLocation.NameKey] = value;
}
/// <summary>
@@ -28,8 +28,8 @@ namespace SabreTools.DatItems.Formats
[JsonProperty("number", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("number")]
public long? Number
{
get => _confLocation.ReadLong(Models.Internal.ConfLocation.NumberKey);
set => _confLocation[Models.Internal.ConfLocation.NumberKey] = value;
get => _internal.ReadLong(Models.Internal.ConfLocation.NumberKey);
set => _internal[Models.Internal.ConfLocation.NumberKey] = value;
}
[JsonIgnore]
@@ -41,19 +41,13 @@ namespace SabreTools.DatItems.Formats
[JsonProperty("inverted", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("inverted")]
public bool? Inverted
{
get => _confLocation.ReadBool(Models.Internal.ConfLocation.InvertedKey);
set => _confLocation[Models.Internal.ConfLocation.InvertedKey] = value;
get => _internal.ReadBool(Models.Internal.ConfLocation.InvertedKey);
set => _internal[Models.Internal.ConfLocation.InvertedKey] = value;
}
[JsonIgnore]
public bool InvertedSpecified { get { return Inverted != null; } }
/// <summary>
/// Internal ConfLocation model
/// </summary>
[JsonIgnore]
private Models.Internal.ConfLocation _confLocation = new();
#endregion
#region Accessors
@@ -73,6 +67,7 @@ namespace SabreTools.DatItems.Formats
/// </summary>
public ConfLocation()
{
_internal = new Models.Internal.ConfLocation();
Name = string.Empty;
ItemType = ItemType.ConfLocation;
}
@@ -93,25 +88,10 @@ namespace SabreTools.DatItems.Formats
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
_confLocation = this._confLocation?.Clone() as Models.Internal.ConfLocation ?? new Models.Internal.ConfLocation(),
_internal = this._internal?.Clone() as Models.Internal.ConfLocation ?? new Models.Internal.ConfLocation(),
};
}
#endregion
#region Comparision Methods
/// <inheritdoc/>
public override bool Equals(DatItem? other)
{
// If we don't have a v, return false
if (ItemType != other?.ItemType || other is not ConfLocation otherInternal)
return false;
// Compare the internal models
return _confLocation.EqualTo(otherInternal._confLocation);
}
#endregion
}
}