using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; using SabreTools.Filter; namespace SabreTools.DatItems.Formats { /// /// Represents which BIOS(es) is associated with a set /// [JsonObject("biosset"), XmlRoot("biosset")] public class BiosSet : DatItem { #region Fields /// /// Name of the item /// [JsonProperty("name"), XmlElement("name")] public string? Name { get => _internal.ReadString(Models.Metadata.BiosSet.NameKey); set => _internal[Models.Metadata.BiosSet.NameKey] = value; } /// /// Description of the BIOS /// [JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("description")] public string? Description { get => _internal.ReadString(Models.Metadata.BiosSet.DescriptionKey); set => _internal[Models.Metadata.BiosSet.DescriptionKey] = value; } /// /// Determine whether the BIOS is default /// [JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")] public bool? Default { get => _internal.ReadBool(Models.Metadata.BiosSet.DefaultKey); set => _internal[Models.Metadata.BiosSet.DefaultKey] = value; } [JsonIgnore] public bool DefaultSpecified { get { return Default != null; } } #endregion #region Accessors /// public override string? GetName() => Name; /// public override void SetName(string? name) => Name = name; #endregion #region Constructors /// /// Create a default, empty BiosSet object /// public BiosSet() { _internal = new Models.Metadata.BiosSet(); Machine = new Machine(); Name = string.Empty; ItemType = ItemType.BiosSet; } #endregion #region Cloning Methods /// public override object Clone() { return new BiosSet() { 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.BiosSet ?? [], }; } #endregion #region Manipulation /// public override bool RemoveField(DatItemField datItemField) { // Get the correct internal field name string? fieldName = datItemField switch { DatItemField.Default => Models.Metadata.BiosSet.DefaultKey, DatItemField.Description => Models.Metadata.BiosSet.DescriptionKey, _ => null, }; // Remove the field and return return FieldManipulator.RemoveField(_internal, fieldName); } #endregion } }