Files
SabreTools.Serialization/SabreTools.Data.Models/Metadata/Port.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2026-04-04 01:36:42 -04:00
using System;
2025-09-26 10:20:48 -04:00
using System.Xml.Serialization;
using Newtonsoft.Json;
2025-09-26 13:06:18 -04:00
namespace SabreTools.Data.Models.Metadata
2025-09-26 10:20:48 -04:00
{
[JsonObject("port"), XmlRoot("port")]
2026-04-04 01:36:42 -04:00
public class Port : DatItem, ICloneable, IEquatable<Port>
2025-09-26 10:20:48 -04:00
{
2026-04-02 11:18:49 -04:00
#region Properties
2026-04-04 01:36:42 -04:00
public Analog[]? Analog { get; set; }
2026-04-02 11:18:49 -04:00
public string? Tag { get; set; }
#endregion
2026-04-04 01:36:42 -04:00
public Port() => ItemType = ItemType.Port;
2025-09-26 10:20:48 -04:00
2026-04-04 01:36:42 -04:00
/// <inheritdoc/>
public object Clone()
{
var obj = new Port();
2025-09-26 10:20:48 -04:00
2026-04-04 01:36:42 -04:00
if (Analog is not null)
obj.Analog = Array.ConvertAll(Analog, i => (Analog)i.Clone());
obj.Tag = Tag;
2025-09-26 10:20:48 -04:00
2026-04-04 01:36:42 -04:00
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;
}
2025-09-26 10:20:48 -04:00
}
}