diff --git a/SabreTools.Serialization/Internal.cs b/SabreTools.Serialization/Internal.cs deleted file mode 100644 index 98617509..00000000 --- a/SabreTools.Serialization/Internal.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using SabreTools.Models.Metadata; - -namespace SabreTools.Serialization -{ - public static class Internal - { - /// - /// Extract nested items from a Dump - /// - public static DatItem[]? ExtractItems(Dump? item) - { - if (item == null) - return null; - - var datItems = new List(); - - var rom = item.Read(Dump.RomKey); - if (rom != null) - datItems.Add(rom); - - var megaRom = item.Read(Dump.MegaRomKey); - if (megaRom != null) - datItems.Add(megaRom); - - var sccPlusCart = item.Read(Dump.SCCPlusCartKey); - if (sccPlusCart != null) - datItems.Add(sccPlusCart); - - return [.. datItems]; - } - - /// - /// Extract nested items from a Part - /// - public static DatItem[]? ExtractItems(Part? item) - { - if (item == null) - return null; - - var datItems = new List(); - - var features = item.Read(Part.FeatureKey); - if (features != null && features.Any()) - datItems.AddRange(features); - - var dataAreas = item.Read(Part.DataAreaKey); - if (dataAreas != null && dataAreas.Any()) - { - datItems.AddRange(dataAreas - .Where(d => d != null) - .SelectMany(ExtractItems) - .Select(d => d as DatItem)); - } - - var diskAreas = item.Read(Part.DiskAreaKey); - if (diskAreas != null && diskAreas.Any()) - { - datItems.AddRange(diskAreas - .Where(d => d != null) - .SelectMany(ExtractItems) - .Select(d => d as DatItem)); - } - - var dipSwitches = item.Read(Part.DipSwitchKey); - if (dipSwitches != null && dipSwitches.Any()) - { - datItems.AddRange(dipSwitches - .Where(d => d != null) - .Select(d => d as DatItem)); - } - - return [.. datItems]; - } - - /// - /// Extract nested items from a DataArea - /// - private static Rom[] ExtractItems(DataArea item) - { - var roms = item.Read(DataArea.RomKey); - if (roms == null || !roms.Any()) - return []; - - return [.. roms]; - } - - /// - /// Extract nested items from a DiskArea - /// - private static Disk[] ExtractItems(DiskArea item) - { - var roms = item.Read(DiskArea.DiskKey); - if (roms == null || !roms.Any()) - return []; - - return [.. roms]; - } - } -} \ No newline at end of file