mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move more to the DatItem base class
This commit is contained in:
@@ -18,8 +18,8 @@ namespace SabreTools.DatItems.Formats
|
||||
[JsonProperty("name"), XmlElement("name")]
|
||||
public string? Name
|
||||
{
|
||||
get => _instance.ReadString(Models.Internal.Instance.NameKey);
|
||||
set => _instance[Models.Internal.Instance.NameKey] = value;
|
||||
get => _internal.ReadString(Models.Internal.Instance.NameKey);
|
||||
set => _internal[Models.Internal.Instance.NameKey] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,16 +28,10 @@ namespace SabreTools.DatItems.Formats
|
||||
[JsonProperty("briefname", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("briefname")]
|
||||
public string? BriefName
|
||||
{
|
||||
get => _instance.ReadString(Models.Internal.Instance.BriefNameKey);
|
||||
set => _instance[Models.Internal.Instance.BriefNameKey] = value;
|
||||
get => _internal.ReadString(Models.Internal.Instance.BriefNameKey);
|
||||
set => _internal[Models.Internal.Instance.BriefNameKey] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal Instance model
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
private Models.Internal.Instance _instance = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
@@ -57,6 +51,7 @@ namespace SabreTools.DatItems.Formats
|
||||
/// </summary>
|
||||
public Instance()
|
||||
{
|
||||
_internal = new Models.Internal.Instance();
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Instance;
|
||||
}
|
||||
@@ -77,25 +72,10 @@ namespace SabreTools.DatItems.Formats
|
||||
Source = this.Source?.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
_instance = this._instance?.Clone() as Models.Internal.Instance ?? new Models.Internal.Instance(),
|
||||
_internal = this._internal?.Clone() as Models.Internal.Instance ?? new Models.Internal.Instance(),
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(DatItem? other)
|
||||
{
|
||||
// If we don't have a Instance, return false
|
||||
if (ItemType != other?.ItemType || other is not Instance otherInternal)
|
||||
return false;
|
||||
|
||||
// Compare the internal models
|
||||
return _instance.EqualTo(otherInternal._instance);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user