From a1ad61f6daffa7e34f03c8e7edb50ad9178a5c3b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 14 Jan 2025 22:34:58 -0500 Subject: [PATCH] Add more passthrough DB methods --- SabreTools.DatFiles/DatFile.Filtering.cs | 2 +- SabreTools.DatFiles/DatFile.Splitting.cs | 10 +++++----- SabreTools.DatFiles/DatFile.cs | 24 ++++++++++++++++++++++++ SabreTools.DatFiles/DatFileTool.cs | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/SabreTools.DatFiles/DatFile.Filtering.cs b/SabreTools.DatFiles/DatFile.Filtering.cs index 000851c1..4a8efbd5 100644 --- a/SabreTools.DatFiles/DatFile.Filtering.cs +++ b/SabreTools.DatFiles/DatFile.Filtering.cs @@ -467,7 +467,7 @@ namespace SabreTools.DatFiles parents[key].Remove(machine); // Remove the rest of the items from this key - parents[key].ForEach(k => ItemsDB.RemoveMachine(k)); + parents[key].ForEach(k => RemoveMachineDB(k)); } // Finally, strip out the parent tags diff --git a/SabreTools.DatFiles/DatFile.Splitting.cs b/SabreTools.DatFiles/DatFile.Splitting.cs index f9bba9d1..a7561f67 100644 --- a/SabreTools.DatFiles/DatFile.Splitting.cs +++ b/SabreTools.DatFiles/DatFile.Splitting.cs @@ -485,7 +485,7 @@ namespace SabreTools.DatFiles } // Remove the current item - ItemsDB.RemoveItem(item.Key); + RemoveItemDB(item.Key); } } } @@ -1059,12 +1059,12 @@ namespace SabreTools.DatFiles { foreach (var key in items.Keys) { - ItemsDB.RemoveItem(key); + RemoveItemDB(key); } } // Remove the machine - ItemsDB.RemoveMachine(machine.Key); + RemoveMachineDB(machine.Key); } } @@ -1149,7 +1149,7 @@ namespace SabreTools.DatFiles var matchedItems = items.Where(i => i.Value.Equals(item.Value)); foreach (var match in matchedItems) { - ItemsDB.RemoveItem(match.Key); + RemoveItemDB(match.Key); } } @@ -1247,7 +1247,7 @@ namespace SabreTools.DatFiles var matchedItems = items.Where(i => i.Value.Equals(item.Value)); foreach (var match in matchedItems) { - ItemsDB.RemoveItem(match.Key); + RemoveItemDB(match.Key); } } } diff --git a/SabreTools.DatFiles/DatFile.cs b/SabreTools.DatFiles/DatFile.cs index 2092fe72..de1b9173 100644 --- a/SabreTools.DatFiles/DatFile.cs +++ b/SabreTools.DatFiles/DatFile.cs @@ -282,6 +282,30 @@ namespace SabreTools.DatFiles return Items.RemoveItem(key, value); } + /// + /// Remove an item, returning if it could be removed + /// + public bool RemoveItemDB(long itemIndex) + { + return ItemsDB.RemoveItem(itemIndex); + } + + /// + /// Remove a machine, returning if it could be removed + /// + public bool RemoveMachineDB(long machineIndex) + { + return ItemsDB.RemoveMachine(machineIndex); + } + + /// + /// Remove a machine, returning if it could be removed + /// + public bool RemoveMachineDB(string machineName) + { + return ItemsDB.RemoveMachine(machineName); + } + /// /// Reset the internal item dictionary /// diff --git a/SabreTools.DatFiles/DatFileTool.cs b/SabreTools.DatFiles/DatFileTool.cs index 085fc6db..49a9cd4d 100644 --- a/SabreTools.DatFiles/DatFileTool.cs +++ b/SabreTools.DatFiles/DatFileTool.cs @@ -1577,7 +1577,7 @@ namespace SabreTools.DatFiles // Now remove the key from the source DAT if (delete) - addFrom.ItemsDB.RemoveItem(item.Key); + addFrom.RemoveItemDB(item.Key); #if NET40_OR_GREATER || NETCOREAPP });