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(); Machine = new Machine(); SetName(string.Empty); ItemType = ItemType.DipValue; } /// /// Create a DipValue object from the internal model /// public DipValue(Models.Metadata.DipValue? item) { _internal = item ?? []; Machine = new Machine(); ItemType = ItemType.DipValue; } #endregion #region Cloning Methods /// public override object Clone() { return new DipValue() { 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.DipValue ?? [], }; } #endregion } }