mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-21 13:49:42 +00:00
81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace SabreTools.Metadata.DatItems.Formats
|
|
{
|
|
/// <summary>
|
|
/// Represents which Device Reference(s) is associated with a set
|
|
/// </summary>
|
|
[JsonObject("device_ref"), XmlRoot("device_ref")]
|
|
public sealed class DeviceRef : DatItem<Data.Models.Metadata.DeviceRef>
|
|
{
|
|
#region Properties
|
|
|
|
/// <inheritdoc>/>
|
|
public override Data.Models.Metadata.ItemType ItemType
|
|
=> Data.Models.Metadata.ItemType.DeviceRef;
|
|
|
|
public string? Name
|
|
{
|
|
get => _internal.Name;
|
|
set => _internal.Name = value;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public DeviceRef() : base() { }
|
|
|
|
public DeviceRef(Data.Models.Metadata.DeviceRef item) : base(item) { }
|
|
|
|
public DeviceRef(Data.Models.Metadata.DeviceRef item, Machine machine, Source source) : this(item)
|
|
{
|
|
Source = source;
|
|
CopyMachineInformation(machine);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Accessors
|
|
|
|
/// <inheritdoc/>
|
|
public override string? GetName() => Name;
|
|
|
|
/// <inheritdoc/>
|
|
public override void SetName(string? name) => Name = name;
|
|
|
|
#endregion
|
|
|
|
#region Cloning Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override object Clone() => new DeviceRef(GetInternalClone());
|
|
|
|
/// <inheritdoc/>
|
|
public override Data.Models.Metadata.DeviceRef GetInternalClone()
|
|
=> _internal.Clone() as Data.Models.Metadata.DeviceRef ?? new();
|
|
|
|
#endregion
|
|
|
|
#region Comparision Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override bool Equals(DatItem? other)
|
|
{
|
|
// If the other item is null
|
|
if (other is null)
|
|
return false;
|
|
|
|
// If the type matches
|
|
if (other is DeviceRef otherDeviceRef)
|
|
return _internal.Equals(otherDeviceRef._internal);
|
|
|
|
// Everything else fails
|
|
return false;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|