diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs index d905325d..b998dc41 100644 --- a/SabreTools.DatItems/DatItem.cs +++ b/SabreTools.DatItems/DatItem.cs @@ -371,6 +371,17 @@ namespace SabreTools.DatItems #endregion + #region Manipulation + + /// + /// Remove a field from the DatItem + /// + /// Item field to remove + /// True if the removal was successful, false otherwise + public abstract bool RemoveField(DatItemField datItemField); + + #endregion + #region Sorting and Merging /// diff --git a/SabreTools.DatItems/Formats/Adjuster.cs b/SabreTools.DatItems/Formats/Adjuster.cs index d8f7075d..2790c009 100644 --- a/SabreTools.DatItems/Formats/Adjuster.cs +++ b/SabreTools.DatItems/Formats/Adjuster.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -97,5 +98,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Default => Models.Metadata.Adjuster.DefaultKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Analog.cs b/SabreTools.DatItems/Formats/Analog.cs index 8be7a46d..6c25e297 100644 --- a/SabreTools.DatItems/Formats/Analog.cs +++ b/SabreTools.DatItems/Formats/Analog.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -58,5 +59,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Analog_Mask => Models.Metadata.Analog.MaskKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Archive.cs b/SabreTools.DatItems/Formats/Archive.cs index 94eef299..90a0c768 100644 --- a/SabreTools.DatItems/Formats/Archive.cs +++ b/SabreTools.DatItems/Formats/Archive.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -134,5 +135,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/BiosSet.cs b/SabreTools.DatItems/Formats/BiosSet.cs index 3006a832..c0c5717f 100644 --- a/SabreTools.DatItems/Formats/BiosSet.cs +++ b/SabreTools.DatItems/Formats/BiosSet.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -92,5 +93,24 @@ namespace SabreTools.DatItems.Formats } #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 } } diff --git a/SabreTools.DatItems/Formats/Blank.cs b/SabreTools.DatItems/Formats/Blank.cs index 6ac8543c..f37cb8b6 100644 --- a/SabreTools.DatItems/Formats/Blank.cs +++ b/SabreTools.DatItems/Formats/Blank.cs @@ -57,5 +57,12 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) => true; + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Chip.cs b/SabreTools.DatItems/Formats/Chip.cs index 17cc4efa..e5270038 100644 --- a/SabreTools.DatItems/Formats/Chip.cs +++ b/SabreTools.DatItems/Formats/Chip.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -108,5 +109,25 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.ChipType => Models.Metadata.Chip.ChipTypeKey, + DatItemField.Clock => Models.Metadata.Chip.ClockKey, + DatItemField.Tag => Models.Metadata.Chip.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Condition.cs b/SabreTools.DatItems/Formats/Condition.cs index c4749f8e..861a477d 100644 --- a/SabreTools.DatItems/Formats/Condition.cs +++ b/SabreTools.DatItems/Formats/Condition.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -94,5 +95,30 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Mask => Models.Metadata.Condition.MaskKey, + DatItemField.Condition_Mask => Models.Metadata.Condition.MaskKey, + DatItemField.Relation => Models.Metadata.Condition.RelationKey, + DatItemField.Condition_Relation => Models.Metadata.Condition.RelationKey, + DatItemField.Tag => Models.Metadata.Condition.TagKey, + DatItemField.Condition_Tag => Models.Metadata.Condition.TagKey, + DatItemField.Value => Models.Metadata.Condition.ValueKey, + DatItemField.Condition_Value => Models.Metadata.Condition.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/ConfLocation.cs b/SabreTools.DatItems/Formats/ConfLocation.cs index 7ae3da39..493d5d1f 100644 --- a/SabreTools.DatItems/Formats/ConfLocation.cs +++ b/SabreTools.DatItems/Formats/ConfLocation.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -95,5 +96,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Inverted => Models.Metadata.ConfLocation.InvertedKey, + DatItemField.Location_Inverted => Models.Metadata.ConfLocation.InvertedKey, + DatItemField.Number => Models.Metadata.ConfLocation.NumberKey, + DatItemField.Location_Number => Models.Metadata.ConfLocation.NumberKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/ConfSetting.cs b/SabreTools.DatItems/Formats/ConfSetting.cs index 73a30369..f6d5c313 100644 --- a/SabreTools.DatItems/Formats/ConfSetting.cs +++ b/SabreTools.DatItems/Formats/ConfSetting.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -107,5 +108,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Default => Models.Metadata.ConfSetting.DefaultKey, + DatItemField.Setting_Default => Models.Metadata.ConfSetting.DefaultKey, + DatItemField.Value => Models.Metadata.ConfSetting.ValueKey, + DatItemField.Setting_Value => Models.Metadata.ConfSetting.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Configuration.cs b/SabreTools.DatItems/Formats/Configuration.cs index ae09d005..0f0ebe14 100644 --- a/SabreTools.DatItems/Formats/Configuration.cs +++ b/SabreTools.DatItems/Formats/Configuration.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -130,5 +131,24 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Mask => Models.Metadata.Configuration.MaskKey, + DatItemField.Tag => Models.Metadata.Configuration.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Control.cs b/SabreTools.DatItems/Formats/Control.cs index c4cc71e8..12553d5a 100644 --- a/SabreTools.DatItems/Formats/Control.cs +++ b/SabreTools.DatItems/Formats/Control.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -198,5 +199,34 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Control_Buttons => Models.Metadata.Control.ButtonsKey, + DatItemField.Control_KeyDelta => Models.Metadata.Control.KeyDeltaKey, + DatItemField.Control_Maximum => Models.Metadata.Control.MaximumKey, + DatItemField.Control_Minimum => Models.Metadata.Control.MinimumKey, + DatItemField.Control_Player => Models.Metadata.Control.PlayerKey, + DatItemField.Control_RequiredButtons => Models.Metadata.Control.ReqButtonsKey, + DatItemField.Control_Reverse => Models.Metadata.Control.ReverseKey, + DatItemField.Control_Sensitivity => Models.Metadata.Control.SensitivityKey, + DatItemField.Control_Type => Models.Metadata.Control.ControlTypeKey, + DatItemField.Control_Ways => Models.Metadata.Control.WaysKey, + DatItemField.Control_Ways2 => Models.Metadata.Control.Ways2Key, + DatItemField.Control_Ways3 => Models.Metadata.Control.Ways3Key, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/DataArea.cs b/SabreTools.DatItems/Formats/DataArea.cs index 0d7b7015..1fa35df7 100644 --- a/SabreTools.DatItems/Formats/DataArea.cs +++ b/SabreTools.DatItems/Formats/DataArea.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -110,5 +111,25 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.AreaEndianness => Models.Metadata.DataArea.EndiannessKey, + DatItemField.AreaSize => Models.Metadata.DataArea.SizeKey, + DatItemField.AreaWidth => Models.Metadata.DataArea.WidthKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Device.cs b/SabreTools.DatItems/Formats/Device.cs index 0608e3fd..8b02c8f6 100644 --- a/SabreTools.DatItems/Formats/Device.cs +++ b/SabreTools.DatItems/Formats/Device.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -136,5 +137,27 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.DeviceType => Models.Metadata.Device.DeviceTypeKey, + DatItemField.FixedImage => Models.Metadata.Device.FixedImageKey, + DatItemField.Interface => Models.Metadata.Device.InterfaceKey, + DatItemField.Mandatory => Models.Metadata.Device.MandatoryKey, + DatItemField.Tag => Models.Metadata.Device.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/DeviceReference.cs b/SabreTools.DatItems/Formats/DeviceReference.cs index e75bbe8c..17e91338 100644 --- a/SabreTools.DatItems/Formats/DeviceReference.cs +++ b/SabreTools.DatItems/Formats/DeviceReference.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -69,5 +70,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/DipLocation.cs b/SabreTools.DatItems/Formats/DipLocation.cs index 0c2ddd85..000ad012 100644 --- a/SabreTools.DatItems/Formats/DipLocation.cs +++ b/SabreTools.DatItems/Formats/DipLocation.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -95,5 +96,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Inverted => Models.Metadata.DipLocation.InvertedKey, + DatItemField.Location_Inverted => Models.Metadata.DipLocation.InvertedKey, + DatItemField.Number => Models.Metadata.DipLocation.NumberKey, + DatItemField.Location_Number => Models.Metadata.DipLocation.NumberKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/DipSwitch.cs b/SabreTools.DatItems/Formats/DipSwitch.cs index b05707b7..92ffc180 100644 --- a/SabreTools.DatItems/Formats/DipSwitch.cs +++ b/SabreTools.DatItems/Formats/DipSwitch.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -158,5 +159,24 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Mask => Models.Metadata.DipSwitch.MaskKey, + DatItemField.Tag => Models.Metadata.DipSwitch.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/DipValue.cs b/SabreTools.DatItems/Formats/DipValue.cs index f509107d..a8027daa 100644 --- a/SabreTools.DatItems/Formats/DipValue.cs +++ b/SabreTools.DatItems/Formats/DipValue.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -107,5 +108,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Default => Models.Metadata.DipValue.DefaultKey, + DatItemField.Setting_Default => Models.Metadata.DipValue.DefaultKey, + DatItemField.Value => Models.Metadata.DipValue.ValueKey, + DatItemField.Setting_Value => Models.Metadata.DipValue.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Disk.cs b/SabreTools.DatItems/Formats/Disk.cs index 12a24ec6..e07370a7 100644 --- a/SabreTools.DatItems/Formats/Disk.cs +++ b/SabreTools.DatItems/Formats/Disk.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; using SabreTools.FileTypes; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -285,6 +286,31 @@ namespace SabreTools.DatItems.Formats #endregion + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Index => Models.Metadata.Disk.IndexKey, + DatItemField.MD5 => Models.Metadata.Disk.MD5Key, + DatItemField.Merge => Models.Metadata.Disk.MergeKey, + DatItemField.Optional => Models.Metadata.Disk.OptionalKey, + DatItemField.Region => Models.Metadata.Disk.RegionKey, + DatItemField.SHA1 => Models.Metadata.Disk.SHA1Key, + DatItemField.Status => Models.Metadata.Disk.StatusKey, + DatItemField.Writable => Models.Metadata.Disk.WritableKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion + #region Sorting and Merging /// diff --git a/SabreTools.DatItems/Formats/DiskArea.cs b/SabreTools.DatItems/Formats/DiskArea.cs index b01537f9..f339b775 100644 --- a/SabreTools.DatItems/Formats/DiskArea.cs +++ b/SabreTools.DatItems/Formats/DiskArea.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -70,5 +71,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Display.cs b/SabreTools.DatItems/Formats/Display.cs index 74bda91e..6a450198 100644 --- a/SabreTools.DatItems/Formats/Display.cs +++ b/SabreTools.DatItems/Formats/Display.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -230,5 +231,36 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.DisplayType => Models.Metadata.Display.DisplayTypeKey, + DatItemField.FlipX => Models.Metadata.Display.FlipXKey, + DatItemField.HBEnd => Models.Metadata.Display.HBEndKey, + DatItemField.HBStart => Models.Metadata.Display.HBStartKey, + DatItemField.Height => Models.Metadata.Display.HeightKey, + DatItemField.HTotal => Models.Metadata.Display.HTotalKey, + DatItemField.PixClock => Models.Metadata.Display.PixClockKey, + DatItemField.Refresh => Models.Metadata.Display.RefreshKey, + DatItemField.Rotate => Models.Metadata.Display.RotateKey, + DatItemField.Tag => Models.Metadata.Display.TagKey, + DatItemField.VBEnd => Models.Metadata.Display.VBEndKey, + DatItemField.VBStart => Models.Metadata.Display.VBStartKey, + DatItemField.VTotal => Models.Metadata.Display.VTotalKey, + DatItemField.Width => Models.Metadata.Display.WidthKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Driver.cs b/SabreTools.DatItems/Formats/Driver.cs index 862a8932..170512aa 100644 --- a/SabreTools.DatItems/Formats/Driver.cs +++ b/SabreTools.DatItems/Formats/Driver.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -161,5 +162,30 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.CocktailStatus => Models.Metadata.Driver.CocktailKey, + DatItemField.EmulationStatus => Models.Metadata.Driver.EmulationKey, + DatItemField.Incomplete => Models.Metadata.Driver.IncompleteKey, + DatItemField.NoSoundHardware => Models.Metadata.Driver.NoSoundHardwareKey, + DatItemField.RequiresArtwork => Models.Metadata.Driver.RequiresArtworkKey, + DatItemField.SaveStateStatus => Models.Metadata.Driver.SaveStateKey, + DatItemField.SupportStatus => Models.Metadata.Driver.StatusKey, + DatItemField.Unofficial => Models.Metadata.Driver.UnofficialKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Extension.cs b/SabreTools.DatItems/Formats/Extension.cs index bcd469ec..ec7d1141 100644 --- a/SabreTools.DatItems/Formats/Extension.cs +++ b/SabreTools.DatItems/Formats/Extension.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -69,5 +70,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Feature.cs b/SabreTools.DatItems/Formats/Feature.cs index 43ec5d16..4dec4825 100644 --- a/SabreTools.DatItems/Formats/Feature.cs +++ b/SabreTools.DatItems/Formats/Feature.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -92,5 +93,25 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.FeatureOverall => Models.Metadata.Feature.OverallKey, + DatItemField.FeatureStatus => Models.Metadata.Feature.StatusKey, + DatItemField.FeatureType => Models.Metadata.Feature.FeatureTypeKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/File.cs b/SabreTools.DatItems/Formats/File.cs index c463107a..3dbf91c4 100644 --- a/SabreTools.DatItems/Formats/File.cs +++ b/SabreTools.DatItems/Formats/File.cs @@ -1,10 +1,10 @@ -using System; using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; using SabreTools.Core.Tools; using SabreTools.FileTypes; +using SabreTools.Filter; using SabreTools.Matching; // TODO: Add item mappings for all fields @@ -326,6 +326,24 @@ namespace SabreTools.DatItems.Formats #endregion + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + // TODO: Figure out what fields go here + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion + #region Sorting and Merging /// diff --git a/SabreTools.DatItems/Formats/Info.cs b/SabreTools.DatItems/Formats/Info.cs index 46cfcdc8..34fc49b5 100644 --- a/SabreTools.DatItems/Formats/Info.cs +++ b/SabreTools.DatItems/Formats/Info.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -79,5 +80,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Value => Models.Metadata.Info.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Input.cs b/SabreTools.DatItems/Formats/Input.cs index 26a52399..2819f959 100644 --- a/SabreTools.DatItems/Formats/Input.cs +++ b/SabreTools.DatItems/Formats/Input.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -115,5 +116,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Coins => Models.Metadata.Input.CoinsKey, + DatItemField.Players => Models.Metadata.Input.PlayersKey, + DatItemField.Service => Models.Metadata.Input.ServiceKey, + DatItemField.Tilt => Models.Metadata.Input.TiltKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Instance.cs b/SabreTools.DatItems/Formats/Instance.cs index 20df842b..316dfd2d 100644 --- a/SabreTools.DatItems/Formats/Instance.cs +++ b/SabreTools.DatItems/Formats/Instance.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -79,5 +80,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Instance_BriefName => Models.Metadata.Instance.BriefNameKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Media.cs b/SabreTools.DatItems/Formats/Media.cs index ddfa1c2a..d27a5832 100644 --- a/SabreTools.DatItems/Formats/Media.cs +++ b/SabreTools.DatItems/Formats/Media.cs @@ -1,9 +1,9 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; using SabreTools.Core.Tools; using SabreTools.FileTypes; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -184,6 +184,27 @@ namespace SabreTools.DatItems.Formats #endregion + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.MD5 => Models.Metadata.Media.MD5Key, + DatItemField.SHA1 => Models.Metadata.Media.SHA1Key, + DatItemField.SHA256 => Models.Metadata.Media.SHA256Key, + DatItemField.SpamSum => Models.Metadata.Media.SpamSumKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion + #region Sorting and Merging /// diff --git a/SabreTools.DatItems/Formats/Part.cs b/SabreTools.DatItems/Formats/Part.cs index 54881a1e..629d138f 100644 --- a/SabreTools.DatItems/Formats/Part.cs +++ b/SabreTools.DatItems/Formats/Part.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -86,5 +87,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Part_Interface => Models.Metadata.Part.InterfaceKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/PartFeature.cs b/SabreTools.DatItems/Formats/PartFeature.cs index 8ede2297..fdbd0ea4 100644 --- a/SabreTools.DatItems/Formats/PartFeature.cs +++ b/SabreTools.DatItems/Formats/PartFeature.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -79,5 +80,24 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Value => Models.Metadata.Feature.ValueKey, + DatItemField.Part_Feature_Value => Models.Metadata.Feature.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Port.cs b/SabreTools.DatItems/Formats/Port.cs index 961b31ba..d2e9e18f 100644 --- a/SabreTools.DatItems/Formats/Port.cs +++ b/SabreTools.DatItems/Formats/Port.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -73,5 +74,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Tag => Models.Metadata.Port.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/RamOption.cs b/SabreTools.DatItems/Formats/RamOption.cs index 8ccff07b..113978ce 100644 --- a/SabreTools.DatItems/Formats/RamOption.cs +++ b/SabreTools.DatItems/Formats/RamOption.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -92,5 +93,24 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Content => Models.Metadata.RamOption.ContentKey, + DatItemField.Default => Models.Metadata.RamOption.DefaultKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Release.cs b/SabreTools.DatItems/Formats/Release.cs index fb37f4d5..cdc028a7 100644 --- a/SabreTools.DatItems/Formats/Release.cs +++ b/SabreTools.DatItems/Formats/Release.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -116,5 +117,26 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Date => Models.Metadata.Release.DateKey, + DatItemField.Default => Models.Metadata.Release.DefaultKey, + DatItemField.Language => Models.Metadata.Release.LanguageKey, + DatItemField.Region => Models.Metadata.Release.RegionKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/ReleaseDetails.cs b/SabreTools.DatItems/Formats/ReleaseDetails.cs index a3c97774..bca73aec 100644 --- a/SabreTools.DatItems/Formats/ReleaseDetails.cs +++ b/SabreTools.DatItems/Formats/ReleaseDetails.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; // TODO: Add item mappings for all fields namespace SabreTools.DatItems.Formats @@ -186,5 +187,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + // TODO: Figure out what fields go here + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Rom.cs b/SabreTools.DatItems/Formats/Rom.cs index d2e7f049..e160959e 100644 --- a/SabreTools.DatItems/Formats/Rom.cs +++ b/SabreTools.DatItems/Formats/Rom.cs @@ -1,10 +1,10 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; using SabreTools.FileTypes; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -597,6 +597,64 @@ namespace SabreTools.DatItems.Formats #endregion + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.AltName => Models.Metadata.Rom.AltRomnameKey, + DatItemField.AltTitle => Models.Metadata.Rom.AltTitleKey, + DatItemField.ArchiveDotOrgFormat => Models.Metadata.Rom.FormatKey, + DatItemField.ArchiveDotOrgSource => Models.Metadata.Rom.SourceKey, + DatItemField.Bios => Models.Metadata.Rom.BiosKey, + //DatItemField.Boot => Models.Metadata.Rom.BootKey, + DatItemField.CRC => Models.Metadata.Rom.CRCKey, + DatItemField.Date => Models.Metadata.Rom.DateKey, + DatItemField.Inverted => Models.Metadata.Rom.InvertedKey, + DatItemField.LoadFlag => Models.Metadata.Rom.LoadFlagKey, + DatItemField.MD5 => Models.Metadata.Rom.MD5Key, + DatItemField.Merge => Models.Metadata.Rom.MergeKey, + DatItemField.MIA => Models.Metadata.Rom.MIAKey, + DatItemField.Offset => Models.Metadata.Rom.OffsetKey, + DatItemField.OpenMSXSubType => Models.Metadata.Rom.OpenMSXMediaType, // TODO: Fix with Key suffix + DatItemField.OpenMSXType => Models.Metadata.Rom.OpenMSXType, // TODO: Fix with Key suffix + DatItemField.Optional => Models.Metadata.Rom.OptionalKey, + //DatItemField.Original => Models.Metadata.Rom.OriginalKey, + DatItemField.OriginalFilename => Models.Metadata.Rom.OriginalKey, + DatItemField.Region => Models.Metadata.Rom.RegionKey, + DatItemField.Remark => Models.Metadata.Rom.RemarkKey, + DatItemField.Rotation => Models.Metadata.Rom.RotationKey, + DatItemField.SHA1 => Models.Metadata.Rom.SHA1Key, + DatItemField.SHA256 => Models.Metadata.Rom.SHA256Key, + DatItemField.SHA384 => Models.Metadata.Rom.SHA384Key, + DatItemField.SHA512 => Models.Metadata.Rom.SHA512Key, + DatItemField.Size => Models.Metadata.Rom.SizeKey, + DatItemField.SpamSum => Models.Metadata.Rom.SpamSumKey, + DatItemField.Status => Models.Metadata.Rom.StatusKey, + DatItemField.Summation => Models.Metadata.Rom.SummationKey, + DatItemField.Value => Models.Metadata.Rom.ValueKey, + _ => null, + }; + + // A null value means special handling is needed + if (fieldName == null) + { + switch (datItemField) + { + case DatItemField.Boot: Boot = null; return true; + case DatItemField.Original: Original = null; return true; + } + } + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion + #region Sorting and Merging /// diff --git a/SabreTools.DatItems/Formats/Sample.cs b/SabreTools.DatItems/Formats/Sample.cs index 18a4b8dd..60279433 100644 --- a/SabreTools.DatItems/Formats/Sample.cs +++ b/SabreTools.DatItems/Formats/Sample.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -69,5 +70,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Serials.cs b/SabreTools.DatItems/Formats/Serials.cs index 5f35fb70..a2d588d6 100644 --- a/SabreTools.DatItems/Formats/Serials.cs +++ b/SabreTools.DatItems/Formats/Serials.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; // TODO: Add item mappings for all fields namespace SabreTools.DatItems.Formats @@ -174,5 +175,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + // TODO: Figure out what fields go here + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/SharedFeature.cs b/SabreTools.DatItems/Formats/SharedFeature.cs index 81d5268f..53494ba7 100644 --- a/SabreTools.DatItems/Formats/SharedFeature.cs +++ b/SabreTools.DatItems/Formats/SharedFeature.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -79,5 +80,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Value => Models.Metadata.SharedFeat.ValueKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Slot.cs b/SabreTools.DatItems/Formats/Slot.cs index 705a0062..dd2a5356 100644 --- a/SabreTools.DatItems/Formats/Slot.cs +++ b/SabreTools.DatItems/Formats/Slot.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -84,5 +85,22 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/SlotOption.cs b/SabreTools.DatItems/Formats/SlotOption.cs index a0cbb118..262e92e6 100644 --- a/SabreTools.DatItems/Formats/SlotOption.cs +++ b/SabreTools.DatItems/Formats/SlotOption.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -92,5 +93,25 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Default => Models.Metadata.SlotOption.DefaultKey, + DatItemField.SlotOption_Default => Models.Metadata.SlotOption.DefaultKey, + DatItemField.SlotOption_DeviceName => Models.Metadata.SlotOption.DevNameKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/SoftwareList.cs b/SabreTools.DatItems/Formats/SoftwareList.cs index 55006817..ae71f37e 100644 --- a/SabreTools.DatItems/Formats/SoftwareList.cs +++ b/SabreTools.DatItems/Formats/SoftwareList.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -111,5 +112,25 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Filter => Models.Metadata.SoftwareList.FilterKey, + DatItemField.SoftwareListStatus => Models.Metadata.SoftwareList.StatusKey, + DatItemField.Tag => Models.Metadata.SoftwareList.TagKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Formats/Sound.cs b/SabreTools.DatItems/Formats/Sound.cs index 0cf84148..aa99c4fe 100644 --- a/SabreTools.DatItems/Formats/Sound.cs +++ b/SabreTools.DatItems/Formats/Sound.cs @@ -1,6 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core; +using SabreTools.Filter; namespace SabreTools.DatItems.Formats { @@ -61,5 +62,23 @@ namespace SabreTools.DatItems.Formats } #endregion + + #region Manipulation + + /// + public override bool RemoveField(DatItemField datItemField) + { + // Get the correct internal field name + string? fieldName = datItemField switch + { + DatItemField.Default => Models.Metadata.Sound.ChannelsKey, + _ => null, + }; + + // Remove the field and return + return FieldManipulator.RemoveField(_internal, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/Machine.cs b/SabreTools.DatItems/Machine.cs index 2a24c9a1..4534f6ef 100644 --- a/SabreTools.DatItems/Machine.cs +++ b/SabreTools.DatItems/Machine.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using SabreTools.Core; using SabreTools.Core.Tools; +using SabreTools.Filter; namespace SabreTools.DatItems { @@ -538,5 +539,82 @@ namespace SabreTools.DatItems } #endregion + + #region Manipulation + + /// + /// Remove a field from the Machine + /// + /// Machine field to remove + /// True if the removal was successful, false otherwise + public bool RemoveField(MachineField machineField) + { + // Get the correct internal field name + string? fieldName = machineField switch + { + MachineField.Board => Models.Metadata.Machine.BoardKey, + MachineField.Buttons => Models.Metadata.Machine.ButtonsKey, + MachineField.Category => Models.Metadata.Machine.CategoryKey, + MachineField.CloneOf => Models.Metadata.Machine.CloneOfKey, + MachineField.CloneOfID => Models.Metadata.Machine.CloneOfIdKey, + MachineField.Comment => Models.Metadata.Machine.CommentKey, + MachineField.Control => Models.Metadata.Machine.ControlKey, + MachineField.Country => Models.Metadata.Machine.CountryKey, + //MachineField.CRC => Models.Metadata.Machine.CRCKey, + MachineField.Description => Models.Metadata.Machine.DescriptionKey, + //MachineField.Developer => Models.Metadata.Machine.DeveloperKey, + MachineField.DisplayCount => Models.Metadata.Machine.DisplayCountKey, + MachineField.DisplayType => Models.Metadata.Machine.DisplayTypeKey, + //MachineField.Enabled => Models.Metadata.Machine.EnabledKey, + MachineField.GenMSXID => Models.Metadata.Machine.GenMSXIDKey, + //MachineField.Genre => Models.Metadata.Machine.GenreKey, + MachineField.History => Models.Metadata.Machine.HistoryKey, + MachineField.ID => Models.Metadata.Machine.IdKey, + MachineField.Manufacturer => Models.Metadata.Machine.ManufacturerKey, + MachineField.Name => Models.Metadata.Machine.NameKey, + MachineField.Players => Models.Metadata.Machine.PlayersKey, + MachineField.Publisher => Models.Metadata.Machine.PublisherKey, + //MachineField.Ratings => Models.Metadata.Machine.RatingsKey, + MachineField.RebuildTo => Models.Metadata.Machine.RebuildToKey, + //MachineField.RelatedTo => Models.Metadata.Machine.RelatedToKey, + MachineField.RomOf => Models.Metadata.Machine.RomOfKey, + MachineField.Rotation => Models.Metadata.Machine.RotationKey, + MachineField.Runnable => Models.Metadata.Machine.RunnableKey, + MachineField.SampleOf => Models.Metadata.Machine.SampleOfKey, + //MachineField.Score => Models.Metadata.Machine.ScoreKey, + MachineField.SourceFile => Models.Metadata.Machine.SourceFileKey, + MachineField.Status => Models.Metadata.Machine.StatusKey, + //MachineField.Subgenre => Models.Metadata.Machine.SubgenreKey, + MachineField.Supported => Models.Metadata.Machine.SupportedKey, + MachineField.System => Models.Metadata.Machine.SystemKey, + //MachineField.TitleID => Models.Metadata.Machine.TitleIDKey, + //MachineField.Type => Models.Metadata.Machine.TypeKey, + MachineField.Year => Models.Metadata.Machine.YearKey, + _ => null, + }; + + // A null value means special handling is needed + if (fieldName == null) + { + switch (machineField) + { + case MachineField.CRC: Crc = null; return true; + case MachineField.Developer: Developer = null; return true; + case MachineField.Enabled: Enabled = null; return true; + case MachineField.Genre: Genre = null; return true; + case MachineField.Ratings: Ratings = null; return true; + case MachineField.RelatedTo: RelatedTo = null; return true; + case MachineField.Score: Score = null; return true; + case MachineField.Subgenre: Subgenre = null; return true; + case MachineField.TitleID: TitleID = null; return true; + case MachineField.Type: MachineType = MachineType.None; return true; + } + } + + // Remove the field and return + return FieldManipulator.RemoveField(_machine, fieldName); + } + + #endregion } } diff --git a/SabreTools.DatItems/SabreTools.DatItems.csproj b/SabreTools.DatItems/SabreTools.DatItems.csproj index 29b0eb00..3b6a9df3 100644 --- a/SabreTools.DatItems/SabreTools.DatItems.csproj +++ b/SabreTools.DatItems/SabreTools.DatItems.csproj @@ -23,6 +23,7 @@ + diff --git a/SabreTools.Filter/FieldManipulator.cs b/SabreTools.Filter/FieldManipulator.cs index 20d28609..2562e283 100644 --- a/SabreTools.Filter/FieldManipulator.cs +++ b/SabreTools.Filter/FieldManipulator.cs @@ -25,6 +25,12 @@ namespace SabreTools.Filter string? name = machine.ReadString(Header.NameKey); string? description = machine.ReadString(Header.DescriptionKey); + // Sanitize the description string + description = description? + .Replace('/', '_') + .Replace("\"", "''") + .Replace(":", " -"); + // Replace the name with the description machine[Header.NameKey] = description; return (true, name); diff --git a/SabreTools.Filter/TypeHelper.cs b/SabreTools.Filter/TypeHelper.cs index 45d5418b..3cc26a1b 100644 --- a/SabreTools.Filter/TypeHelper.cs +++ b/SabreTools.Filter/TypeHelper.cs @@ -1,8 +1,10 @@ using System; using System.Linq; using System.Reflection; +#if NET452_OR_GREATER || NETCOREAPP using System.Xml.Serialization; using SabreTools.Models; +#endif using SabreTools.Models.Metadata; namespace SabreTools.Filter diff --git a/SabreTools.Filtering/DatItemRemover.cs b/SabreTools.Filtering/DatItemRemover.cs index 0d7e11e4..5074a6e1 100644 --- a/SabreTools.Filtering/DatItemRemover.cs +++ b/SabreTools.Filtering/DatItemRemover.cs @@ -65,7 +65,7 @@ namespace SabreTools.Filtering /// Remove fields with given values /// /// DatItem to remove fields from - public void RemoveFields(DatItem datItem) + public void RemoveFields(DatItem? datItem) { if (datItem == null) return; @@ -85,42 +85,27 @@ namespace SabreTools.Filtering #region Item-Specific - if (datItem is Adjuster adjuster) RemoveFields(adjuster); - else if (datItem is Analog analog) RemoveFields(analog); - else if (datItem is Archive archive) RemoveFields(archive); - else if (datItem is BiosSet biosSet) RemoveFields(biosSet); - else if (datItem is Chip chip) RemoveFields(chip); - else if (datItem is Condition condition) RemoveFields(condition); - else if (datItem is Configuration configuration) RemoveFields(configuration); - else if (datItem is ConfLocation confLocation) RemoveFields(confLocation); - else if (datItem is ConfSetting confSetting) RemoveFields(confSetting); - else if (datItem is Control control) RemoveFields(control); - else if (datItem is DataArea dataArea) RemoveFields(dataArea); - else if (datItem is Device device) RemoveFields(device); - else if (datItem is DipLocation dipLocation) RemoveFields(dipLocation); - else if (datItem is DipSwitch dipSwitch) RemoveFields(dipSwitch); - else if (datItem is DipValue dipValue) RemoveFields(dipValue); - else if (datItem is Disk disk) RemoveFields(disk); - else if (datItem is DiskArea diskArea) RemoveFields(diskArea); - else if (datItem is Display display) RemoveFields(display); - else if (datItem is Driver driver) RemoveFields(driver); - else if (datItem is Extension extension) RemoveFields(extension); - else if (datItem is Feature feature) RemoveFields(feature); - else if (datItem is Info info) RemoveFields(info); - else if (datItem is Input input) RemoveFields(input); - else if (datItem is Instance instance) RemoveFields(instance); - else if (datItem is Media media) RemoveFields(media); - else if (datItem is Part part) RemoveFields(part); - else if (datItem is PartFeature partFeature) RemoveFields(partFeature); - else if (datItem is Port port) RemoveFields(port); - else if (datItem is RamOption ramOption) RemoveFields(ramOption); - else if (datItem is Release release) RemoveFields(release); - else if (datItem is Rom rom) RemoveFields(rom); - else if (datItem is SharedFeature sharedFeature) RemoveFields(sharedFeature); - else if (datItem is Slot slot) RemoveFields(slot); - else if (datItem is SlotOption slotOption) RemoveFields(slotOption); - else if (datItem is SoftwareList softwareList) RemoveFields(softwareList); - else if (datItem is Sound sound) RemoveFields(sound); + // Handle unnested removals first + foreach (var datItemField in DatItemFields) + { + datItem.RemoveField(datItemField); + } + + // Handle nested removals + switch (datItem) + { + case Adjuster adjuster: RemoveFields(adjuster); break; + case Configuration configuration: RemoveFields(configuration); break; + case ConfSetting confSetting: RemoveFields(confSetting); break; + case Device device: RemoveFields(device); break; + case DipSwitch dipSwitch: RemoveFields(dipSwitch); break; + case DipValue dipValue: RemoveFields(dipValue); break; + case Disk disk: RemoveFields(disk); break; + case Input input: RemoveFields(input); break; + case Port port: RemoveFields(port); break; + case Rom rom: RemoveFields(rom); break; + case Slot slot: RemoveFields(slot); break; + } #endregion } @@ -131,119 +116,10 @@ namespace SabreTools.Filtering /// Machine to remove fields from private void RemoveFields(Machine machine) { - if (MachineFields.Contains(MachineField.Board)) - machine.Board = null; - - if (MachineFields.Contains(MachineField.Buttons)) - machine.Buttons = null; - - if (MachineFields.Contains(MachineField.Category)) - machine.Category = null; - - if (MachineFields.Contains(MachineField.CloneOf)) - machine.CloneOf = null; - - if (MachineFields.Contains(MachineField.CloneOfID)) - machine.NoIntroCloneOfId = null; - - if (MachineFields.Contains(MachineField.Comment)) - machine.Comment = null; - - if (MachineFields.Contains(MachineField.Control)) - machine.Control = null; - - if (MachineFields.Contains(MachineField.Country)) - machine.Country = null; - - if (MachineFields.Contains(MachineField.CRC)) - machine.Crc = null; - - if (MachineFields.Contains(MachineField.Description)) - machine.Description = null; - - if (MachineFields.Contains(MachineField.Developer)) - machine.Developer = null; - - if (MachineFields.Contains(MachineField.DisplayCount)) - machine.DisplayCount = null; - - if (MachineFields.Contains(MachineField.DisplayType)) - machine.DisplayType = null; - - if (MachineFields.Contains(MachineField.Enabled)) - machine.Enabled = null; - - if (MachineFields.Contains(MachineField.GenMSXID)) - machine.GenMSXID = null; - - if (MachineFields.Contains(MachineField.Genre)) - machine.Genre = null; - - if (MachineFields.Contains(MachineField.History)) - machine.History = null; - - if (MachineFields.Contains(MachineField.ID)) - machine.NoIntroId = null; - - if (MachineFields.Contains(MachineField.Manufacturer)) - machine.Manufacturer = null; - - if (MachineFields.Contains(MachineField.Name)) - machine.Name = null; - - if (MachineFields.Contains(MachineField.Players)) - machine.Players = null; - - if (MachineFields.Contains(MachineField.Publisher)) - machine.Publisher = null; - - if (MachineFields.Contains(MachineField.Ratings)) - machine.Ratings = null; - - if (MachineFields.Contains(MachineField.RebuildTo)) - machine.RebuildTo = null; - - if (MachineFields.Contains(MachineField.RelatedTo)) - machine.RelatedTo = null; - - if (MachineFields.Contains(MachineField.RomOf)) - machine.RomOf = null; - - if (MachineFields.Contains(MachineField.Rotation)) - machine.Rotation = null; - - if (MachineFields.Contains(MachineField.Runnable)) - machine.Runnable = Runnable.NULL; - - if (MachineFields.Contains(MachineField.SampleOf)) - machine.SampleOf = null; - - if (MachineFields.Contains(MachineField.Score)) - machine.Score = null; - - if (MachineFields.Contains(MachineField.SourceFile)) - machine.SourceFile = null; - - if (MachineFields.Contains(MachineField.Status)) - machine.Status = null; - - if (MachineFields.Contains(MachineField.Subgenre)) - machine.Subgenre = null; - - if (MachineFields.Contains(MachineField.Supported)) - machine.Supported = Supported.NULL; - - if (MachineFields.Contains(MachineField.System)) - machine.System = null; - - if (MachineFields.Contains(MachineField.TitleID)) - machine.TitleID = null; - - if (MachineFields.Contains(MachineField.Type)) - machine.MachineType = 0x0; - - if (MachineFields.Contains(MachineField.Year)) - machine.Year = null; + foreach (var machineField in MachineFields) + { + machine.RemoveField(machineField); + } } /// @@ -252,125 +128,12 @@ namespace SabreTools.Filtering /// Adjuster to remove fields from private void RemoveFields(Adjuster adjuster) { - if (DatItemFields.Contains(DatItemField.Default)) - adjuster.Default = null; + if (!adjuster.ConditionsSpecified) + return; - if (adjuster.ConditionsSpecified) + foreach (Condition subCondition in adjuster.Conditions!) { - foreach (Condition subCondition in adjuster.Conditions!) - { - RemoveFields(subCondition, true); - } - } - } - - /// - /// Remove fields with given values - /// - /// Analog to remove fields from - private void RemoveFields(Analog analog) - { - if (DatItemFields.Contains(DatItemField.Analog_Mask)) - analog.Mask = null; - } - - /// - /// Remove fields with given values - /// - /// Archive to remove fields from - private void RemoveFields(Archive archive) - { - if (DatItemFields.Contains(DatItemField.Categories)) - archive.Categories = null; - - if (DatItemFields.Contains(DatItemField.Clone)) - archive.CloneValue = null; - - if (DatItemFields.Contains(DatItemField.Complete)) - archive.Complete = null; - - if (DatItemFields.Contains(DatItemField.DevStatus)) - archive.DevStatus = null; - - if (DatItemFields.Contains(DatItemField.Languages)) - archive.Languages = null; - - if (DatItemFields.Contains(DatItemField.Number)) - archive.Number = null; - - if (DatItemFields.Contains(DatItemField.Physical)) - archive.Physical = null; - - if (DatItemFields.Contains(DatItemField.Region)) - archive.Region = null; - - if (DatItemFields.Contains(DatItemField.RegParent)) - archive.RegParent = null; - } - - /// - /// Remove fields with given values - /// - /// BiosSet to remove fields from - private void RemoveFields(BiosSet biosSet) - { - if (DatItemFields.Contains(DatItemField.Default)) - biosSet.Default = null; - - if (DatItemFields.Contains(DatItemField.Description)) - biosSet.Description = null; - } - - /// - /// Remove fields with given values - /// - /// Chip to remove fields from - private void RemoveFields(Chip chip) - { - if (DatItemFields.Contains(DatItemField.ChipType)) - chip.ChipType = ChipType.NULL; - - if (DatItemFields.Contains(DatItemField.Clock)) - chip.Clock = null; - - if (DatItemFields.Contains(DatItemField.Tag)) - chip.Tag = null; - } - - /// - /// Remove fields with given values - /// - /// Condition to remove fields from - /// True if this is a subitem, false otherwise - private void RemoveFields(Condition condition, bool sub = false) - { - if (sub) - { - if (DatItemFields.Contains(DatItemField.Condition_Mask)) - condition.Mask = null; - - if (DatItemFields.Contains(DatItemField.Condition_Relation)) - condition.Relation = Relation.NULL; - - if (DatItemFields.Contains(DatItemField.Condition_Tag)) - condition.Tag = null; - - if (DatItemFields.Contains(DatItemField.Condition_Value)) - condition.Value = null; - } - else - { - if (DatItemFields.Contains(DatItemField.Mask)) - condition.Mask = null; - - if (DatItemFields.Contains(DatItemField.Relation)) - condition.Relation = Relation.NULL; - - if (DatItemFields.Contains(DatItemField.Tag)) - condition.Tag = null; - - if (DatItemFields.Contains(DatItemField.Value)) - condition.Value = null; + RemoveFields(subCondition); } } @@ -380,17 +143,11 @@ namespace SabreTools.Filtering /// Configuration to remove fields from private void RemoveFields(Configuration configuration) { - if (DatItemFields.Contains(DatItemField.Mask)) - configuration.Mask = null; - - if (DatItemFields.Contains(DatItemField.Tag)) - configuration.Tag = null; - if (configuration.ConditionsSpecified) { foreach (Condition subCondition in configuration.Conditions!) { - RemoveFields(subCondition, true); + RemoveFields(subCondition); } } @@ -406,134 +163,32 @@ namespace SabreTools.Filtering { foreach (ConfSetting subSetting in configuration.Settings!) { - RemoveFields(subSetting); + RemoveFields(subSetting as DatItem); } } } - /// - /// Remove fields with given values - /// - /// ConfLocation to remove fields from - private void RemoveFields(ConfLocation confLocation) - { - if (DatItemFields.Contains(DatItemField.Location_Inverted)) - confLocation.Inverted = null; - - if (DatItemFields.Contains(DatItemField.Location_Name)) - confLocation.Name = null; - - if (DatItemFields.Contains(DatItemField.Location_Number)) - confLocation.Number = null; - } - /// /// Remove fields with given values /// /// ConfSetting to remove fields from private void RemoveFields(ConfSetting confsetting) { - if (DatItemFields.Contains(DatItemField.Setting_Default)) - confsetting.Default = null; - - if (DatItemFields.Contains(DatItemField.Setting_Name)) - confsetting.Name = null; - - if (DatItemFields.Contains(DatItemField.Setting_Value)) - confsetting.Value = null; - if (confsetting.ConditionsSpecified) { foreach (Condition subCondition in confsetting.Conditions!) { - RemoveFields(subCondition, true); + RemoveFields(subCondition); } } } - /// - /// Remove fields with given values - /// - /// Control to remove fields from - private void RemoveFields(Control control) - { - if (DatItemFields.Contains(DatItemField.Control_Buttons)) - control.Buttons = null; - - if (DatItemFields.Contains(DatItemField.Control_KeyDelta)) - control.KeyDelta = null; - - if (DatItemFields.Contains(DatItemField.Control_Maximum)) - control.Maximum = null; - - if (DatItemFields.Contains(DatItemField.Control_Minimum)) - control.Minimum = null; - - if (DatItemFields.Contains(DatItemField.Control_Player)) - control.Player = null; - - if (DatItemFields.Contains(DatItemField.Control_RequiredButtons)) - control.RequiredButtons = null; - - if (DatItemFields.Contains(DatItemField.Control_Reverse)) - control.Reverse = null; - - if (DatItemFields.Contains(DatItemField.Control_Sensitivity)) - control.Sensitivity = null; - - if (DatItemFields.Contains(DatItemField.Control_Type)) - control.ControlType = ControlType.NULL; - - if (DatItemFields.Contains(DatItemField.Control_Ways)) - control.Ways = null; - - if (DatItemFields.Contains(DatItemField.Control_Ways2)) - control.Ways2 = null; - - if (DatItemFields.Contains(DatItemField.Control_Ways3)) - control.Ways3 = null; - } - - /// - /// Remove fields with given values - /// - /// DataArea to remove fields from - private void RemoveFields(DataArea dataArea) - { - if (DatItemFields.Contains(DatItemField.AreaEndianness)) - dataArea.Endianness = Endianness.NULL; - - if (DatItemFields.Contains(DatItemField.AreaName)) - dataArea.Name = null; - - if (DatItemFields.Contains(DatItemField.AreaSize)) - dataArea.Size = null; - - if (DatItemFields.Contains(DatItemField.AreaWidth)) - dataArea.Width = null; - } - /// /// Remove fields with given values /// /// Device to remove fields from private void RemoveFields(Device device) { - if (DatItemFields.Contains(DatItemField.DeviceType)) - device.DeviceType = DeviceType.NULL; - - if (DatItemFields.Contains(DatItemField.FixedImage)) - device.FixedImage = null; - - if (DatItemFields.Contains(DatItemField.Interface)) - device.Interface = null; - - if (DatItemFields.Contains(DatItemField.Tag)) - device.Tag = null; - - if (DatItemFields.Contains(DatItemField.Mandatory)) - device.Mandatory = null; - if (device.ExtensionsSpecified) { foreach (Extension subExtension in device.Extensions!) @@ -551,39 +206,17 @@ namespace SabreTools.Filtering } } - /// - /// Remove fields with given values - /// - /// DipLocation to remove fields from - private void RemoveFields(DipLocation dipLocation) - { - if (DatItemFields.Contains(DatItemField.Location_Inverted)) - dipLocation.Inverted = null; - - if (DatItemFields.Contains(DatItemField.Location_Name)) - dipLocation.Name = null; - - if (DatItemFields.Contains(DatItemField.Location_Number)) - dipLocation.Number = null; - } - /// /// Remove fields with given values /// /// DipSwitch to remove fields from private void RemoveFields(DipSwitch dipSwitch) { - if (DatItemFields.Contains(DatItemField.Mask)) - dipSwitch.Mask = null; - - if (DatItemFields.Contains(DatItemField.Tag)) - dipSwitch.Tag = null; - if (dipSwitch.ConditionsSpecified) { foreach (Condition subCondition in dipSwitch.Conditions!) { - RemoveFields(subCondition, true); + RemoveFields(subCondition); } } @@ -599,12 +232,12 @@ namespace SabreTools.Filtering { foreach (DipValue subValue in dipSwitch.Values!) { - RemoveFields(subValue); + RemoveFields(subValue as DatItem); } } if (dipSwitch.PartSpecified) - RemoveFields(dipSwitch.Part!); + RemoveFields(dipSwitch.Part! as DatItem); } /// @@ -613,20 +246,11 @@ namespace SabreTools.Filtering /// DipValue to remove fields from private void RemoveFields(DipValue dipValue) { - if (DatItemFields.Contains(DatItemField.Setting_Default)) - dipValue.Default = null; - - if (DatItemFields.Contains(DatItemField.Setting_Name)) - dipValue.Name = null; - - if (DatItemFields.Contains(DatItemField.Setting_Value)) - dipValue.Value = null; - if (dipValue.ConditionsSpecified) { foreach (Condition subCondition in dipValue.Conditions!) { - RemoveFields(subCondition, true); + RemoveFields(subCondition); } } } @@ -637,161 +261,11 @@ namespace SabreTools.Filtering /// Disk to remove fields from private void RemoveFields(Disk disk) { - if (DatItemFields.Contains(DatItemField.Index)) - disk.Index = null; - - if (DatItemFields.Contains(DatItemField.Status)) - disk.ItemStatus = ItemStatus.NULL; - - if (DatItemFields.Contains(DatItemField.MD5)) - disk.MD5 = null; - - if (DatItemFields.Contains(DatItemField.Merge)) - disk.MergeTag = null; - - if (DatItemFields.Contains(DatItemField.Optional)) - disk.Optional = null; - - if (DatItemFields.Contains(DatItemField.Region)) - disk.Region = null; - - if (DatItemFields.Contains(DatItemField.SHA1)) - disk.SHA1 = null; - - if (DatItemFields.Contains(DatItemField.Writable)) - disk.Writable = null; - if (disk.DiskAreaSpecified) - RemoveFields(disk.DiskArea!); + RemoveFields(disk.DiskArea); if (disk.PartSpecified) - RemoveFields(disk.Part!); - } - - /// - /// Remove fields with given values - /// - /// DiskArea to remove fields from - private void RemoveFields(DiskArea diskArea) - { - if (DatItemFields.Contains(DatItemField.AreaName)) - diskArea.Name = null; - } - - /// - /// Remove fields with given values - /// - /// Display to remove fields from - private void RemoveFields(Display display) - { - if (DatItemFields.Contains(DatItemField.DisplayType)) - display.DisplayType = DisplayType.NULL; - - if (DatItemFields.Contains(DatItemField.FlipX)) - display.FlipX = null; - - if (DatItemFields.Contains(DatItemField.HBEnd)) - display.HBEnd = null; - - if (DatItemFields.Contains(DatItemField.HBStart)) - display.HBStart = null; - - if (DatItemFields.Contains(DatItemField.Height)) - display.Height = null; - - if (DatItemFields.Contains(DatItemField.HTotal)) - display.HTotal = null; - - if (DatItemFields.Contains(DatItemField.PixClock)) - display.PixClock = null; - - if (DatItemFields.Contains(DatItemField.Refresh)) - display.Refresh = null; - - if (DatItemFields.Contains(DatItemField.Rotate)) - display.Rotate = null; - - if (DatItemFields.Contains(DatItemField.Tag)) - display.Tag = null; - - if (DatItemFields.Contains(DatItemField.VBEnd)) - display.VBEnd = null; - - if (DatItemFields.Contains(DatItemField.VBStart)) - display.VBStart = null; - - if (DatItemFields.Contains(DatItemField.VTotal)) - display.VTotal = null; - - if (DatItemFields.Contains(DatItemField.Width)) - display.Width = null; - } - - /// - /// Remove fields with given values - /// - /// Driver to remove fields from - private void RemoveFields(Driver driver) - { - if (DatItemFields.Contains(DatItemField.CocktailStatus)) - driver.Cocktail = SupportStatus.NULL; - - if (DatItemFields.Contains(DatItemField.EmulationStatus)) - driver.Emulation = SupportStatus.NULL; - - if (DatItemFields.Contains(DatItemField.Incomplete)) - driver.Incomplete = null; - - if (DatItemFields.Contains(DatItemField.NoSoundHardware)) - driver.NoSoundHardware = null; - - if (DatItemFields.Contains(DatItemField.RequiresArtwork)) - driver.RequiresArtwork = null; - - if (DatItemFields.Contains(DatItemField.SaveStateStatus)) - driver.SaveState = Supported.NULL; - - if (DatItemFields.Contains(DatItemField.SupportStatus)) - driver.Status = SupportStatus.NULL; - - if (DatItemFields.Contains(DatItemField.Unofficial)) - driver.Unofficial = null; - } - - /// - /// Remove fields with given values - /// - /// Extension to remove fields from - private void RemoveFields(Extension extension) - { - if (DatItemFields.Contains(DatItemField.Extension_Name)) - extension.Name = null; - } - - /// - /// Remove fields with given values - /// - /// Feature to remove fields from - private void RemoveFields(Feature feature) - { - if (DatItemFields.Contains(DatItemField.FeatureOverall)) - feature.Overall = FeatureStatus.NULL; - - if (DatItemFields.Contains(DatItemField.FeatureStatus)) - feature.Status = FeatureStatus.NULL; - - if (DatItemFields.Contains(DatItemField.FeatureType)) - feature.Type = FeatureType.NULL; - } - - /// - /// Remove fields with given values - /// - /// Info to remove fields from - private void RemoveFields(Info info) - { - if (DatItemFields.Contains(DatItemField.Value)) - info.Value = null; + RemoveFields(disk.Part! as DatItem); } /// @@ -800,18 +274,6 @@ namespace SabreTools.Filtering /// Input to remove fields from private void RemoveFields(Input input) { - if (DatItemFields.Contains(DatItemField.Coins)) - input.Coins = null; - - if (DatItemFields.Contains(DatItemField.Players)) - input.Players = 0; - - if (DatItemFields.Contains(DatItemField.Service)) - input.Service = null; - - if (DatItemFields.Contains(DatItemField.Tilt)) - input.Tilt = null; - if (input.ControlsSpecified) { foreach (Control subControl in input.Controls!) @@ -821,50 +283,12 @@ namespace SabreTools.Filtering } } - /// - /// Remove fields with given values - /// - /// Instance to remove fields from - private void RemoveFields(Instance instance) - { - if (DatItemFields.Contains(DatItemField.Instance_BriefName)) - instance.BriefName = null; - - if (DatItemFields.Contains(DatItemField.Instance_Name)) - instance.Name = null; - } - - /// - /// Remove fields with given values - /// - /// Media to remove fields from - private void RemoveFields(Media media) - { - if (DatItemFields.Contains(DatItemField.MD5)) - media.MD5 = null; - - if (DatItemFields.Contains(DatItemField.SHA1)) - media.SHA1 = null; - - if (DatItemFields.Contains(DatItemField.SHA256)) - media.SHA256 = null; - - if (DatItemFields.Contains(DatItemField.SpamSum)) - media.SpamSum = null; - } - /// /// Remove fields with given values /// /// Part to remove fields from private void RemoveFields(Part part) { - if (DatItemFields.Contains(DatItemField.Part_Interface)) - part.Interface = null; - - if (DatItemFields.Contains(DatItemField.Part_Name)) - part.Name = null; - if (part.FeaturesSpecified) { foreach (PartFeature subPartFeature in part.Features!) @@ -874,28 +298,12 @@ namespace SabreTools.Filtering } } - /// - /// Remove fields with given values - /// - /// PartFeature to remove fields from - private void RemoveFields(PartFeature partFeature) - { - if (DatItemFields.Contains(DatItemField.Part_Feature_Name)) - partFeature.Name = null; - - if (DatItemFields.Contains(DatItemField.Part_Feature_Value)) - partFeature.Value = null; - } - /// /// Remove fields with given values /// /// Port to remove fields from private void RemoveFields(Port port) { - if (DatItemFields.Contains(DatItemField.Tag)) - port.Tag = null; - if (port.AnalogsSpecified) { foreach (Analog subAnalog in port.Analogs!) @@ -905,137 +313,12 @@ namespace SabreTools.Filtering } } - /// - /// Remove fields with given values - /// - /// RamOption to remove fields from - private void RemoveFields(RamOption ramOption) - { - if (DatItemFields.Contains(DatItemField.Content)) - ramOption.Content = null; - - if (DatItemFields.Contains(DatItemField.Default)) - ramOption.Default = null; - } - - /// - /// Remove fields with given values - /// - /// Release to remove fields from - private void RemoveFields(Release release) - { - if (DatItemFields.Contains(DatItemField.Date)) - release.Date = null; - - if (DatItemFields.Contains(DatItemField.Default)) - release.Default = null; - - if (DatItemFields.Contains(DatItemField.Language)) - release.Language = null; - - if (DatItemFields.Contains(DatItemField.Region)) - release.Region = null; - } - /// /// Remove fields with given values /// /// Rom to remove fields from private void RemoveFields(Rom rom) { - if (DatItemFields.Contains(DatItemField.AltName)) - rom.AltName = null; - - if (DatItemFields.Contains(DatItemField.AltTitle)) - rom.AltTitle = null; - - if (DatItemFields.Contains(DatItemField.ArchiveDotOrgFormat)) - rom.ArchiveDotOrgFormat = null; - - if (DatItemFields.Contains(DatItemField.ArchiveDotOrgSource)) - rom.ArchiveDotOrgSource = null; - - if (DatItemFields.Contains(DatItemField.Bios)) - rom.Bios = null; - - if (DatItemFields.Contains(DatItemField.Boot)) - rom.Boot = null; - - if (DatItemFields.Contains(DatItemField.CRC)) - rom.CRC = null; - - if (DatItemFields.Contains(DatItemField.Date)) - rom.Date = null; - - if (DatItemFields.Contains(DatItemField.Inverted)) - rom.Inverted = null; - - if (DatItemFields.Contains(DatItemField.LoadFlag)) - rom.LoadFlag = LoadFlag.NULL; - - if (DatItemFields.Contains(DatItemField.MD5)) - rom.MD5 = null; - - if (DatItemFields.Contains(DatItemField.Merge)) - rom.MergeTag = null; - - if (DatItemFields.Contains(DatItemField.MIA)) - rom.MIA = null; - - if (DatItemFields.Contains(DatItemField.Offset)) - rom.Offset = null; - - if (DatItemFields.Contains(DatItemField.OpenMSXSubType)) - rom.OpenMSXSubType = OpenMSXSubType.NULL; - - if (DatItemFields.Contains(DatItemField.OpenMSXType)) - rom.OpenMSXType = null; - - if (DatItemFields.Contains(DatItemField.Optional)) - rom.Optional = null; - - if (DatItemFields.Contains(DatItemField.Original)) - rom.Original = null; - - if (DatItemFields.Contains(DatItemField.OriginalFilename)) - rom.OriginalFilename = null; - - if (DatItemFields.Contains(DatItemField.Region)) - rom.Region = null; - - if (DatItemFields.Contains(DatItemField.Remark)) - rom.Remark = null; - - if (DatItemFields.Contains(DatItemField.Rotation)) - rom.Rotation = null; - - if (DatItemFields.Contains(DatItemField.SHA1)) - rom.SHA1 = null; - - if (DatItemFields.Contains(DatItemField.SHA256)) - rom.SHA256 = null; - - if (DatItemFields.Contains(DatItemField.SHA384)) - rom.SHA384 = null; - - if (DatItemFields.Contains(DatItemField.SHA512)) - rom.SHA512 = null; - - if (DatItemFields.Contains(DatItemField.Size)) - rom.Size = 0; - - if (DatItemFields.Contains(DatItemField.SpamSum)) - rom.SpamSum = null; - - if (DatItemFields.Contains(DatItemField.Status)) - rom.ItemStatus = ItemStatus.NULL; - - if (DatItemFields.Contains(DatItemField.Summation)) - rom.Summation = null; - - if (DatItemFields.Contains(DatItemField.Value)) - rom.Value = null; - if (rom.DataAreaSpecified) RemoveFields(rom.DataArea!); @@ -1043,16 +326,6 @@ namespace SabreTools.Filtering RemoveFields(rom.Part!); } - /// - /// Remove fields with given values - /// - /// SharedFeature to remove fields from - private void RemoveFields(SharedFeature sharedFeature) - { - if (DatItemFields.Contains(DatItemField.Value)) - sharedFeature.Value = null; - } - /// /// Remove fields with given values /// @@ -1068,48 +341,6 @@ namespace SabreTools.Filtering } } - /// - /// Remove fields with given values - /// - /// SlotOption to remove fields from - private void RemoveFields(SlotOption slotOption) - { - if (DatItemFields.Contains(DatItemField.SlotOption_Default)) - slotOption.Default = null; - - if (DatItemFields.Contains(DatItemField.SlotOption_DeviceName)) - slotOption.DeviceName = null; - - if (DatItemFields.Contains(DatItemField.SlotOption_Name)) - slotOption.Name = null; - } - - /// - /// Remove fields with given values - /// - /// SoftwareList to remove fields from - private void RemoveFields(SoftwareList softwareList) - { - if (DatItemFields.Contains(DatItemField.Filter)) - softwareList.Filter = null; - - if (DatItemFields.Contains(DatItemField.SoftwareListStatus)) - softwareList.Status = SoftwareListStatus.None; - - if (DatItemFields.Contains(DatItemField.Tag)) - softwareList.Tag = null; - } - - /// - /// Remove fields with given values - /// - /// Sound to remove fields from - private void RemoveFields(Sound sound) - { - if (DatItemFields.Contains(DatItemField.Channels)) - sound.Channels = null; - } - #endregion } } \ No newline at end of file