From ae3bae2d0a64dcef9aae5cd3f2046e6c26ba9cbf Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 18 Sep 2020 17:12:31 -0700 Subject: [PATCH] Add explicit list of supported types --- SabreTools.Library/DatFiles/AttractMode.cs | 6 ++++ SabreTools.Library/DatFiles/ClrMamePro.cs | 15 ++++++++++ SabreTools.Library/DatFiles/DatFile.cs | 14 +++++++++- SabreTools.Library/DatFiles/DosCenter.cs | 6 ++++ SabreTools.Library/DatFiles/EverdriveSmdb.cs | 6 ++++ SabreTools.Library/DatFiles/Hashfile.cs | 6 ++++ SabreTools.Library/DatFiles/Listrom.cs | 6 ++++ SabreTools.Library/DatFiles/Listxml.cs | 28 +++++++++++++++++++ SabreTools.Library/DatFiles/Logiqx.cs | 15 ++++++++++ SabreTools.Library/DatFiles/OfflineList.cs | 6 ++++ SabreTools.Library/DatFiles/OpenMSX.cs | 6 ++++ SabreTools.Library/DatFiles/RomCenter.cs | 6 ++++ SabreTools.Library/DatFiles/SeparatedValue.cs | 6 ++++ SabreTools.Library/DatFiles/SoftwareList.cs | 13 +++++++++ 14 files changed, 138 insertions(+), 1 deletion(-) diff --git a/SabreTools.Library/DatFiles/AttractMode.cs b/SabreTools.Library/DatFiles/AttractMode.cs index cb181f84..6410aaf8 100644 --- a/SabreTools.Library/DatFiles/AttractMode.cs +++ b/SabreTools.Library/DatFiles/AttractMode.cs @@ -111,6 +111,12 @@ namespace SabreTools.Library.DatFiles svr.Dispose(); } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/ClrMamePro.cs b/SabreTools.Library/DatFiles/ClrMamePro.cs index 260db0ad..1fd27ba6 100644 --- a/SabreTools.Library/DatFiles/ClrMamePro.cs +++ b/SabreTools.Library/DatFiles/ClrMamePro.cs @@ -407,6 +407,21 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] + { + ItemType.Archive, + ItemType.BiosSet, + ItemType.Disk, + ItemType.Media, + ItemType.Release, + ItemType.Rom, + ItemType.Sample, + }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index aed63cc8..8682ca80 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -2339,7 +2339,6 @@ namespace SabreTools.Library.DatFiles #endregion - // TODO: See if any of the helper methods can be broken up a bit more neatly #region Rebuilding and Verifying /// @@ -3777,6 +3776,15 @@ namespace SabreTools.Library.DatFiles return rom; } + /// + /// Get supported types for write + /// + /// List of supported types for writing + protected virtual ItemType[] GetSupportedTypes() + { + return Enum.GetValues(typeof(ItemType)) as ItemType[]; + } + /// /// Get if an item should be ignored on write /// @@ -3803,6 +3811,10 @@ namespace SabreTools.Library.DatFiles return true; } + // If we have an item type not in the list of supported values + if (!GetSupportedTypes().Contains(datItem.ItemType)) + return true; + return false; } diff --git a/SabreTools.Library/DatFiles/DosCenter.cs b/SabreTools.Library/DatFiles/DosCenter.cs index 8daff200..e55b5792 100644 --- a/SabreTools.Library/DatFiles/DosCenter.cs +++ b/SabreTools.Library/DatFiles/DosCenter.cs @@ -247,6 +247,12 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/EverdriveSmdb.cs b/SabreTools.Library/DatFiles/EverdriveSmdb.cs index 88b010ee..2d583629 100644 --- a/SabreTools.Library/DatFiles/EverdriveSmdb.cs +++ b/SabreTools.Library/DatFiles/EverdriveSmdb.cs @@ -83,6 +83,12 @@ namespace SabreTools.Library.DatFiles sr.Dispose(); } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/Hashfile.cs b/SabreTools.Library/DatFiles/Hashfile.cs index 6ba5aa4b..ce6e5437 100644 --- a/SabreTools.Library/DatFiles/Hashfile.cs +++ b/SabreTools.Library/DatFiles/Hashfile.cs @@ -98,6 +98,12 @@ namespace SabreTools.Library.DatFiles sr.Dispose(); } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/Listrom.cs b/SabreTools.Library/DatFiles/Listrom.cs index 3c8c9a4d..8bd57f7a 100644 --- a/SabreTools.Library/DatFiles/Listrom.cs +++ b/SabreTools.Library/DatFiles/Listrom.cs @@ -250,6 +250,12 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Disk, ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index c5986adb..1a6c5cff 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -1126,6 +1126,34 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] + { + ItemType.Adjuster, + ItemType.BiosSet, + ItemType.Chip, + ItemType.Condition, + ItemType.Configuration, + ItemType.Device, + ItemType.DeviceReference, + ItemType.DipSwitch, + ItemType.Disk, + ItemType.Display, + ItemType.Driver, + ItemType.Feature, + ItemType.Input, + ItemType.Port, + ItemType.RamOption, + ItemType.Rom, + ItemType.Sample, + ItemType.Slot, + ItemType.SoftwareList, + ItemType.Sound, + }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/Logiqx.cs b/SabreTools.Library/DatFiles/Logiqx.cs index b0ab9cec..9106277a 100644 --- a/SabreTools.Library/DatFiles/Logiqx.cs +++ b/SabreTools.Library/DatFiles/Logiqx.cs @@ -658,6 +658,21 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] + { + ItemType.Archive, + ItemType.BiosSet, + ItemType.Disk, + ItemType.Media, + ItemType.Release, + ItemType.Rom, + ItemType.Sample, + }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/OfflineList.cs b/SabreTools.Library/DatFiles/OfflineList.cs index cc994a9b..cbf4b632 100644 --- a/SabreTools.Library/DatFiles/OfflineList.cs +++ b/SabreTools.Library/DatFiles/OfflineList.cs @@ -654,6 +654,12 @@ namespace SabreTools.Library.DatFiles return roms; } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/OpenMSX.cs b/SabreTools.Library/DatFiles/OpenMSX.cs index b66eb367..08ca3de5 100644 --- a/SabreTools.Library/DatFiles/OpenMSX.cs +++ b/SabreTools.Library/DatFiles/OpenMSX.cs @@ -508,6 +508,12 @@ namespace SabreTools.Library.DatFiles return null; } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/RomCenter.cs b/SabreTools.Library/DatFiles/RomCenter.cs index 586281ba..0b562dbe 100644 --- a/SabreTools.Library/DatFiles/RomCenter.cs +++ b/SabreTools.Library/DatFiles/RomCenter.cs @@ -361,6 +361,12 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/SeparatedValue.cs b/SabreTools.Library/DatFiles/SeparatedValue.cs index d24cc679..4b50af37 100644 --- a/SabreTools.Library/DatFiles/SeparatedValue.cs +++ b/SabreTools.Library/DatFiles/SeparatedValue.cs @@ -99,6 +99,12 @@ namespace SabreTools.Library.DatFiles svr.Dispose(); } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; + } + /// /// Create and open an output file for writing direct from a dictionary /// diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index be617922..294a9d7d 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -500,6 +500,19 @@ namespace SabreTools.Library.DatFiles } } + /// + protected override ItemType[] GetSupportedTypes() + { + return new ItemType[] + { + ItemType.DipSwitch, + ItemType.Disk, + ItemType.Info, + ItemType.Rom, + ItemType.SharedFeature, + }; + } + /// /// Create and open an output file for writing direct from a dictionary ///