mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-20 21:29:48 +00:00
52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System;
|
|
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace SabreTools.Data.Models.Metadata
|
|
{
|
|
[JsonObject("port"), XmlRoot("port")]
|
|
public class Port : DatItem, ICloneable, IEquatable<Port>
|
|
{
|
|
#region Properties
|
|
|
|
public Analog[]? Analog { get; set; }
|
|
|
|
public string? Tag { get; set; }
|
|
|
|
#endregion
|
|
|
|
public Port() => ItemType = ItemType.Port;
|
|
|
|
/// <inheritdoc/>
|
|
public object Clone()
|
|
{
|
|
var obj = new Port();
|
|
|
|
if (Analog is not null)
|
|
obj.Analog = Array.ConvertAll(Analog, i => (Analog)i.Clone());
|
|
obj.Tag = Tag;
|
|
|
|
return obj;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public bool Equals(Port? other)
|
|
{
|
|
// Null never matches
|
|
if (other is null)
|
|
return false;
|
|
|
|
// Properties
|
|
if ((Tag is null) ^ (other.Tag is null))
|
|
return false;
|
|
else if (Tag is not null && !Tag.Equals(other.Tag, StringComparison.OrdinalIgnoreCase))
|
|
return false;
|
|
|
|
// Sub-items
|
|
// TODO: Figure out how to properly check arrays
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|