2020-09-02 17:22:31 -07:00
|
|
|
|
using System.Collections.Generic;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
using System.Linq;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 17:22:31 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-02 17:22:31 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-02 17:22:31 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a single port on a machine
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("port"), XmlRoot("port")]
|
2020-09-02 17:22:31 -07:00
|
|
|
|
public class Port : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tag for the port
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tag")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Tag
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadString(Models.Internal.Port.TagKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Port.TagKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 17:22:31 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// List of analogs on the port
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("analogs", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("analogs")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<Analog>? Analogs
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.Read<Analog[]>(Models.Internal.Port.AnalogKey)?.ToList();
|
|
|
|
|
|
set => _internal[Models.Internal.Port.AnalogKey] = value?.ToArray();
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 17:22:31 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool AnalogsSpecified { get { return Analogs != null && Analogs.Count > 0; } }
|
|
|
|
|
|
|
2020-09-02 17:22:31 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Port object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Port()
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = new Models.Internal.Port();
|
2020-09-02 17:22:31 -07:00
|
|
|
|
ItemType = ItemType.Port;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 17:22:31 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Port()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Machine = this.Machine?.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source?.Clone() as Source,
|
2020-09-02 17:22:31 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = this._internal?.Clone() as Models.Internal.Port ?? new Models.Internal.Port(),
|
2020-09-02 17:22:31 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|