Files
SabreTools/SabreTools.DatItems/Formats/ConfLocation.cs

100 lines
2.8 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
namespace SabreTools.DatItems.Formats
{
/// <summary>
/// Represents one conflocation
/// </summary>
[JsonObject("conflocation"), XmlRoot("conflocation")]
public class ConfLocation : DatItem
{
#region Fields
/// <summary>
/// Location name
/// </summary>
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadString(Models.Internal.ConfLocation.NameKey);
set => _internal[Models.Internal.ConfLocation.NameKey] = value;
}
/// <summary>
/// Location ID
/// </summary>
[JsonProperty("number", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("number")]
public long? Number
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.ConfLocation.NumberKey);
set => _internal[Models.Internal.ConfLocation.NumberKey] = value;
}
[JsonIgnore]
public bool NumberSpecified { get { return Number != null; } }
/// <summary>
/// Determines if location is inverted or not
/// </summary>
[JsonProperty("inverted", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("inverted")]
public bool? Inverted
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadBool(Models.Internal.ConfLocation.InvertedKey);
set => _internal[Models.Internal.ConfLocation.InvertedKey] = value;
}
[JsonIgnore]
public bool InvertedSpecified { get { return Inverted != null; } }
#endregion
#region Accessors
/// <inheritdoc/>
public override string? GetName() => Name;
/// <inheritdoc/>
public override void SetName(string? name) => Name = name;
#endregion
#region Constructors
/// <summary>
/// Create a default, empty ConfLocation object
/// </summary>
public ConfLocation()
{
2023-08-14 22:33:05 -04:00
_internal = new Models.Internal.ConfLocation();
2023-08-15 01:38:01 -04:00
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.ConfLocation;
}
#endregion
#region Cloning Methods
/// <inheritdoc/>
public override object Clone()
{
return new ConfLocation()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
2023-08-15 01:38:01 -04:00
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
2023-08-14 22:33:05 -04:00
_internal = this._internal?.Clone() as Models.Internal.ConfLocation ?? new Models.Internal.ConfLocation(),
};
}
#endregion
}
}