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:
@@ -8,55 +8,22 @@ namespace SabreTools.DatItems.Formats
|
||||
/// Represents a single instance of another item
|
||||
/// </summary>
|
||||
[JsonObject("instance"), XmlRoot("instance")]
|
||||
public class Instance : DatItem
|
||||
public sealed class Instance : DatItem<Models.Metadata.Instance>
|
||||
{
|
||||
#region Accessors
|
||||
#region Fields
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string? GetName() => GetFieldValue<string>(Models.Metadata.Instance.NameKey);
|
||||
/// <inheritdoc>/>
|
||||
protected override ItemType ItemType => ItemType.Instance;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string? name) => SetFieldValue(Models.Metadata.Instance.NameKey, name);
|
||||
/// <inheritdoc>/>
|
||||
protected override string? NameKey => Models.Metadata.Instance.NameKey;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Instance object
|
||||
/// </summary>
|
||||
public Instance()
|
||||
{
|
||||
_internal = new Models.Metadata.Instance();
|
||||
|
||||
SetName(string.Empty);
|
||||
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Instance);
|
||||
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an Instance object from the internal model
|
||||
/// </summary>
|
||||
public Instance(Models.Metadata.Instance item)
|
||||
{
|
||||
_internal = item;
|
||||
|
||||
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Instance);
|
||||
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object Clone()
|
||||
{
|
||||
return new Instance()
|
||||
{
|
||||
_internal = this._internal?.Clone() as Models.Metadata.Instance ?? [],
|
||||
};
|
||||
}
|
||||
public Instance() : base() { }
|
||||
public Instance(Models.Metadata.Instance item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user