mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Convert remaining items, add NameKey
This commit is contained in:
@@ -9,10 +9,16 @@ namespace SabreTools.DatItems.Formats
|
||||
/// </summary>
|
||||
/// <remarks>One Part can contain multiple PartFeature, DataArea, DiskArea, and DipSwitch items</remarks>
|
||||
[JsonObject("part"), XmlRoot("part")]
|
||||
public class Part : DatItem
|
||||
public sealed class Part : DatItem<Models.Metadata.Part>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <inheritdoc>/>
|
||||
protected override ItemType ItemType => ItemType.Part;
|
||||
|
||||
/// <inheritdoc>/>
|
||||
protected override string? NameKey => Models.Metadata.Part.NameKey;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool FeaturesSpecified
|
||||
{
|
||||
@@ -25,53 +31,10 @@ namespace SabreTools.DatItems.Formats
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string? GetName() => GetFieldValue<string>(Models.Metadata.Part.NameKey);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string? name) => SetFieldValue(Models.Metadata.Part.NameKey, name);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Part object
|
||||
/// </summary>
|
||||
public Part()
|
||||
{
|
||||
_internal = new Models.Metadata.Part();
|
||||
|
||||
SetName(string.Empty);
|
||||
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Part);
|
||||
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Part object from the internal model
|
||||
/// </summary>
|
||||
public Part(Models.Metadata.Part item)
|
||||
{
|
||||
_internal = item;
|
||||
|
||||
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Part);
|
||||
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object Clone()
|
||||
{
|
||||
return new Part()
|
||||
{
|
||||
_internal = this._internal?.Clone() as Models.Metadata.Part ?? [],
|
||||
};
|
||||
}
|
||||
public Part() : base() { }
|
||||
public Part(Models.Metadata.Part item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user