using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; namespace SabreTools.DatItems.Formats { /// /// Represents one ListXML dipvalue /// [JsonObject("dipvalue"), XmlRoot("dipvalue")] public class DipValue : DatItem { #region Fields [JsonIgnore] public bool ConditionsSpecified { get { var conditions = GetFieldValue(Models.Metadata.DipValue.ConditionKey); return conditions != null && conditions.Length > 0; } } #endregion #region Accessors /// public override string? GetName() => GetFieldValue(Models.Metadata.DipValue.NameKey); /// public override void SetName(string? name) => SetFieldValue(Models.Metadata.DipValue.NameKey, name); #endregion #region Constructors /// /// Create a default, empty DipValue object /// public DipValue() { _internal = new Models.Metadata.DipValue(); SetName(string.Empty); SetFieldValue(Models.Metadata.DatItem.TypeKey, ItemType.DipValue); SetFieldValue(DatItem.MachineKey, new Machine()); } /// /// Create a DipValue object from the internal model /// public DipValue(Models.Metadata.DipValue item) { _internal = item; SetFieldValue(Models.Metadata.DatItem.TypeKey, ItemType.DipValue); SetFieldValue(DatItem.MachineKey, new Machine()); } #endregion #region Cloning Methods /// public override object Clone() { return new DipValue() { _internal = this._internal?.Clone() as Models.Metadata.DipValue ?? [], }; } #endregion } }