using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
namespace SabreTools.DatItems.Formats
{
///
/// Represents a single port on a machine
///
[JsonObject("port"), XmlRoot("port")]
public class Port : DatItem
{
#region Fields
[JsonIgnore]
public bool AnalogsSpecified
{
get
{
var analogs = GetFieldValue(Models.Metadata.Port.AnalogKey);
return analogs != null && analogs.Length > 0;
}
}
#endregion
#region Constructors
///
/// Create a default, empty Port object
///
public Port()
{
_internal = new Models.Metadata.Port();
Machine = new Machine();
ItemType = ItemType.Port;
}
///
/// Create a Port object from the internal model
///
public Port(Models.Metadata.Port? item)
{
_internal = item ?? [];
Machine = new Machine();
ItemType = ItemType.Port;
}
#endregion
#region Cloning Methods
///
public override object Clone()
{
return new Port()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
_internal = this._internal?.Clone() as Models.Metadata.Port ?? [],
};
}
#endregion
}
}