using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; namespace SabreTools.DatItems.Formats { /// /// Represents one diplocation /// [JsonObject("diplocation"), XmlRoot("diplocation")] public class DipLocation : DatItem { #region Fields /// /// Location name /// [JsonProperty("name"), XmlElement("name")] public string? Name { get => _internal.ReadString(Models.Internal.DipLocation.NameKey); set => _internal[Models.Internal.DipLocation.NameKey] = value; } /// /// Location ID /// [JsonProperty("number", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("number")] public long? Number { get => _internal.ReadLong(Models.Internal.DipLocation.NameKey); set => _internal[Models.Internal.DipLocation.NameKey] = value; } [JsonIgnore] public bool NumberSpecified { get { return Number != null; } } /// /// Determines if location is inverted or not /// [JsonProperty("inverted", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("inverted")] public bool? Inverted { get => _internal.ReadBool(Models.Internal.DipLocation.InvertedKey); set => _internal[Models.Internal.DipLocation.InvertedKey] = value; } [JsonIgnore] public bool InvertedSpecified { get { return Inverted != null; } } #endregion #region Accessors /// public override string? GetName() => Name; /// public override void SetName(string? name) => Name = name; #endregion #region Constructors /// /// Create a default, empty DipLocation object /// public DipLocation() { _internal = new Models.Internal.DipLocation(); Machine = new Machine(); Name = string.Empty; ItemType = ItemType.DipLocation; } #endregion #region Cloning Methods /// public override object Clone() { return new DipLocation() { 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.Internal.DipLocation ?? new Models.Internal.DipLocation(), }; } #endregion } }