2020-12-14 10:58:43 -08:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 12:19:12 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-08-31 23:01:51 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-08-31 23:01:51 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents which Device Reference(s) is associated with a set
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("device_ref"), XmlRoot("device_ref")]
|
2020-08-31 23:01:51 -07:00
|
|
|
|
public class DeviceReference : DatItem
|
|
|
|
|
|
{
|
2020-09-02 12:19:12 -07:00
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
|
public override string? GetName() => GetFieldValue<string>(Models.Metadata.DeviceRef.NameKey);
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
|
public override void SetName(string? name) => SetFieldValue(Models.Metadata.DeviceRef.NameKey, name);
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-02 12:19:12 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-08-31 23:01:51 -07:00
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty DeviceReference object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DeviceReference()
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
_internal = new Models.Metadata.DeviceRef();
|
2023-08-15 01:38:01 -04:00
|
|
|
|
Machine = new Machine();
|
|
|
|
|
|
|
2024-03-08 20:42:24 -05:00
|
|
|
|
SetName(string.Empty);
|
2020-08-31 23:01:51 -07:00
|
|
|
|
ItemType = ItemType.DeviceReference;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-09 21:46:38 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a DeviceReference object from the internal model
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DeviceReference(Models.Metadata.DeviceRef? item)
|
|
|
|
|
|
{
|
|
|
|
|
|
_internal = item ?? [];
|
|
|
|
|
|
Machine = new Machine();
|
|
|
|
|
|
|
|
|
|
|
|
ItemType = ItemType.DeviceReference;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-31 23:01:51 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-08-31 23:01:51 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DeviceReference()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
2023-08-15 01:38:01 -04:00
|
|
|
|
Machine = this.Machine.Clone() as Machine ?? new Machine(),
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Source = this.Source?.Clone() as Source,
|
2020-08-31 23:01:51 -07:00
|
|
|
|
Remove = this.Remove,
|
2020-09-03 13:01:33 -07:00
|
|
|
|
|
2024-02-28 19:19:50 -05:00
|
|
|
|
_internal = this._internal?.Clone() as Models.Metadata.DeviceRef ?? [],
|
2020-08-31 23:01:51 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|