diff --git a/SabreTools.Core/Prepare.cs b/SabreTools.Core/Prepare.cs index f776e80a..5b91a1e9 100644 --- a/SabreTools.Core/Prepare.cs +++ b/SabreTools.Core/Prepare.cs @@ -12,8 +12,8 @@ namespace SabreTools.Core /// /// The current toolset version to be used by all child applications /// - public readonly static string Version = $"v1.0.6"; - //public readonly static string Version = $"v1.0.6-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}"; + //public readonly static string Version = $"v1.0.6"; + public readonly static string Version = $"v1.0.6-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}"; /// /// Readies the console and outputs the header diff --git a/SabreTools.DatFiles/Formats/AttractMode.cs b/SabreTools.DatFiles/Formats/AttractMode.cs index 64efc6aa..d66ba175 100644 --- a/SabreTools.DatFiles/Formats/AttractMode.cs +++ b/SabreTools.DatFiles/Formats/AttractMode.cs @@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse an AttractMode DAT and return all found games within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -123,13 +117,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/ClrMamePro.cs b/SabreTools.DatFiles/Formats/ClrMamePro.cs index d3ef8853..98d868dd 100644 --- a/SabreTools.DatFiles/Formats/ClrMamePro.cs +++ b/SabreTools.DatFiles/Formats/ClrMamePro.cs @@ -37,13 +37,7 @@ namespace SabreTools.DatFiles.Formats Quotes = quotes; } - /// - /// Parse a ClrMamePro DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -139,49 +133,49 @@ namespace SabreTools.DatFiles.Formats switch (itemKey) { case "name": - Header.Name = Header.Name ?? itemVal; - superdat = superdat || itemVal.Contains(" - SuperDAT"); + Header.Name ??= itemVal; + superdat |= itemVal.Contains(" - SuperDAT"); if (keep && superdat) - Header.Type = Header.Type ?? "SuperDAT"; + Header.Type ??= "SuperDAT"; break; case "description": - Header.Description = Header.Description ?? itemVal; + Header.Description ??= itemVal; break; case "rootdir": - Header.RootDir = Header.RootDir ?? itemVal; + Header.RootDir ??= itemVal; break; case "category": - Header.Category = Header.Category ?? itemVal; + Header.Category ??= itemVal; break; case "version": - Header.Version = Header.Version ?? itemVal; + Header.Version ??= itemVal; break; case "date": - Header.Date = Header.Date ?? itemVal; + Header.Date ??= itemVal; break; case "author": - Header.Author = Header.Author ?? itemVal; + Header.Author ??= itemVal; break; case "email": - Header.Email = Header.Email ?? itemVal; + Header.Email ??= itemVal; break; case "homepage": - Header.Homepage = Header.Homepage ?? itemVal; + Header.Homepage ??= itemVal; break; case "url": - Header.Url = Header.Url ?? itemVal; + Header.Url ??= itemVal; break; case "comment": - Header.Comment = Header.Comment ?? itemVal; + Header.Comment ??= itemVal; break; case "header": - Header.HeaderSkipper = Header.HeaderSkipper ?? itemVal; + Header.HeaderSkipper ??= itemVal; break; case "type": - Header.Type = Header.Type ?? itemVal; - superdat = superdat || itemVal.Contains("SuperDAT"); + Header.Type ??= itemVal; + superdat |= itemVal.Contains("SuperDAT"); break; case "forcemerging": if (Header.ForceMerging == MergingFlag.None) @@ -442,13 +436,7 @@ namespace SabreTools.DatFiles.Formats }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/DosCenter.cs b/SabreTools.DatFiles/Formats/DosCenter.cs index 6e1ce0db..6b9d85e2 100644 --- a/SabreTools.DatFiles/Formats/DosCenter.cs +++ b/SabreTools.DatFiles/Formats/DosCenter.cs @@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a DOSCenter DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -119,25 +113,25 @@ namespace SabreTools.DatFiles.Formats switch (itemKey) { case "name": - Header.Name = Header.Name ?? itemVal; + Header.Name ??= itemVal; break; case "description": - Header.Description = Header.Description ?? itemVal; + Header.Description ??= itemVal; break; case "dersion": - Header.Version = Header.Version ?? itemVal; + Header.Version ??= itemVal; break; case "date": - Header.Date = Header.Date ?? itemVal; + Header.Date ??= itemVal; break; case "author": - Header.Author = Header.Author ?? itemVal; + Header.Author ??= itemVal; break; case "homepage": - Header.Homepage = Header.Homepage ?? itemVal; + Header.Homepage ??= itemVal; break; case "comment": - Header.Comment = Header.Comment ?? itemVal; + Header.Comment ??= itemVal; break; } } @@ -268,13 +262,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/EverdriveSmdb.cs b/SabreTools.DatFiles/Formats/EverdriveSmdb.cs index 1a0317ef..865bdb14 100644 --- a/SabreTools.DatFiles/Formats/EverdriveSmdb.cs +++ b/SabreTools.DatFiles/Formats/EverdriveSmdb.cs @@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse an Everdrive SMDB file and return all found games within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -114,13 +108,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/Hashfile.cs b/SabreTools.DatFiles/Formats/Hashfile.cs index f03d97b5..8fac5ebc 100644 --- a/SabreTools.DatFiles/Formats/Hashfile.cs +++ b/SabreTools.DatFiles/Formats/Hashfile.cs @@ -29,13 +29,7 @@ namespace SabreTools.DatFiles.Formats _hash = hash; } - /// - /// Parse a hashfile or SFV and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -115,13 +109,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/Listrom.cs b/SabreTools.DatFiles/Formats/Listrom.cs index e8f19bf2..faf79549 100644 --- a/SabreTools.DatFiles/Formats/Listrom.cs +++ b/SabreTools.DatFiles/Formats/Listrom.cs @@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a MAME Listrom DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// /// /// In a new style MAME listrom DAT, each game has the following format: /// @@ -269,13 +263,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Disk, ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/Listxml.cs b/SabreTools.DatFiles/Formats/Listxml.cs index 77a7916b..f1546c91 100644 --- a/SabreTools.DatFiles/Formats/Listxml.cs +++ b/SabreTools.DatFiles/Formats/Listxml.cs @@ -190,13 +190,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a MAME XML DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -230,18 +224,18 @@ namespace SabreTools.DatFiles.Formats switch (xtr.Name) { case "mame": - Header.Name = Header.Name ?? xtr.GetAttribute("build"); - Header.Description = Header.Description ?? Header.Name; - Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo(); - Header.MameConfig = Header.MameConfig ?? xtr.GetAttribute("mameconfig"); + Header.Name ??= xtr.GetAttribute("build"); + Header.Description ??= Header.Name; + Header.Debug ??= xtr.GetAttribute("debug").AsYesNo(); + Header.MameConfig ??= xtr.GetAttribute("mameconfig"); xtr.Read(); break; // Handle M1 DATs since they're 99% the same as a SL DAT case "m1": - Header.Name = Header.Name ?? "M1"; - Header.Description = Header.Description ?? "M1"; - Header.Version = Header.Version ?? xtr.GetAttribute("version") ?? string.Empty; + Header.Name ??= "M1"; + Header.Description ??= "M1"; + Header.Version ??= xtr.GetAttribute("version") ?? string.Empty; xtr.Read(); break; @@ -1352,13 +1346,7 @@ namespace SabreTools.DatFiles.Formats }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/Logiqx.cs b/SabreTools.DatFiles/Formats/Logiqx.cs index 7cd3967f..ca9a1b29 100644 --- a/SabreTools.DatFiles/Formats/Logiqx.cs +++ b/SabreTools.DatFiles/Formats/Logiqx.cs @@ -132,13 +132,7 @@ namespace SabreTools.DatFiles.Formats _deprecated = deprecated; } - /// - /// Parse a Logiqx XML DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -179,8 +173,8 @@ namespace SabreTools.DatFiles.Formats { // The datafile tag can have some attributes case "datafile": - Header.Build = Header.Build ?? xtr.GetAttribute("build"); - Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo(); + Header.Build ??= xtr.GetAttribute("build"); + Header.Debug ??= xtr.GetAttribute("debug").AsYesNo(); xtr.Read(); break; @@ -261,57 +255,57 @@ namespace SabreTools.DatFiles.Formats { case "name": content = reader.ReadElementContentAsString(); - Header.Name = Header.Name ?? content; - superdat = superdat || content.Contains(" - SuperDAT"); + Header.Name ??= content; + superdat |= content.Contains(" - SuperDAT"); if (keep && superdat) { - Header.Type = Header.Type ?? "SuperDAT"; + Header.Type ??= "SuperDAT"; } break; case "description": content = reader.ReadElementContentAsString(); - Header.Description = Header.Description ?? content; + Header.Description ??= content; break; case "rootdir": // This is exclusive to TruRip XML content = reader.ReadElementContentAsString(); - Header.RootDir = Header.RootDir ?? content; + Header.RootDir ??= content; break; case "category": content = reader.ReadElementContentAsString(); - Header.Category = Header.Category ?? content; + Header.Category ??= content; break; case "version": content = reader.ReadElementContentAsString(); - Header.Version = Header.Version ?? content; + Header.Version ??= content; break; case "date": content = reader.ReadElementContentAsString(); - Header.Date = Header.Date ?? content.Replace(".", "/"); + Header.Date ??= content.Replace(".", "/"); break; case "author": content = reader.ReadElementContentAsString(); - Header.Author = Header.Author ?? content; + Header.Author ??= content; break; case "email": content = reader.ReadElementContentAsString(); - Header.Email = Header.Email ?? content; + Header.Email ??= content; break; case "homepage": content = reader.ReadElementContentAsString(); - Header.Homepage = Header.Homepage ?? content; + Header.Homepage ??= content; break; case "url": content = reader.ReadElementContentAsString(); - Header.Url = Header.Url ?? content; + Header.Url ??= content; break; case "comment": @@ -321,8 +315,8 @@ namespace SabreTools.DatFiles.Formats case "type": // This is exclusive to TruRip XML content = reader.ReadElementContentAsString(); - Header.Type = Header.Type ?? content; - superdat = superdat || content.Contains("SuperDAT"); + Header.Type ??= content; + superdat |= content.Contains("SuperDAT"); break; case "clrmamepro": @@ -781,13 +775,7 @@ namespace SabreTools.DatFiles.Formats }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/Missfile.cs b/SabreTools.DatFiles/Formats/Missfile.cs index c1da3c3d..75a0265a 100644 --- a/SabreTools.DatFiles/Formats/Missfile.cs +++ b/SabreTools.DatFiles/Formats/Missfile.cs @@ -21,26 +21,14 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a Missfile and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // There is no consistent way to parse a missfile... throw new NotImplementedException(); } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/OfflineList.cs b/SabreTools.DatFiles/Formats/OfflineList.cs index 227723eb..7687c22a 100644 --- a/SabreTools.DatFiles/Formats/OfflineList.cs +++ b/SabreTools.DatFiles/Formats/OfflineList.cs @@ -26,13 +26,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse an OfflineList XML DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings @@ -132,34 +126,34 @@ namespace SabreTools.DatFiles.Formats { case "datname": content = reader.ReadElementContentAsString(); - Header.Name = Header.Name ?? content; - superdat = superdat || content.Contains(" - SuperDAT"); + Header.Name ??= content; + superdat |= content.Contains(" - SuperDAT"); if (keep && superdat) { - Header.Type = Header.Type ?? "SuperDAT"; + Header.Type ??= "SuperDAT"; } break; case "datversion": content = reader.ReadElementContentAsString(); - Header.Version = Header.Version ?? content; + Header.Version ??= content; break; case "system": content = reader.ReadElementContentAsString(); - Header.System = Header.System ?? content; + Header.System ??= content; break; // TODO: Int32? case "screenshotswidth": content = reader.ReadElementContentAsString(); - Header.ScreenshotsWidth = Header.ScreenshotsWidth ?? content; + Header.ScreenshotsWidth ??= content; break; // TODO: Int32? case "screenshotsheight": content = reader.ReadElementContentAsString(); - Header.ScreenshotsHeight = Header.ScreenshotsHeight ?? content; + Header.ScreenshotsHeight ??= content; break; case "infos": @@ -194,7 +188,7 @@ namespace SabreTools.DatFiles.Formats case "romtitle": content = reader.ReadElementContentAsString(); - Header.RomTitle = Header.RomTitle ?? content; + Header.RomTitle ??= content; break; default: @@ -674,13 +668,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/OpenMSX.cs b/SabreTools.DatFiles/Formats/OpenMSX.cs index f73d7082..5e334109 100644 --- a/SabreTools.DatFiles/Formats/OpenMSX.cs +++ b/SabreTools.DatFiles/Formats/OpenMSX.cs @@ -40,13 +40,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a openMSX softawre list XML DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -80,9 +74,9 @@ namespace SabreTools.DatFiles.Formats switch (xtr.Name) { case "softwaredb": - Header.Name = Header.Name ?? "openMSX Software List"; - Header.Description = Header.Description ?? Header.Name; - Header.Date = Header.Date ?? xtr.GetAttribute("timestamp"); + Header.Name ??= "openMSX Software List"; + Header.Description ??= Header.Name; + Header.Date ??= xtr.GetAttribute("timestamp"); xtr.Read(); break; @@ -542,13 +536,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/RomCenter.cs b/SabreTools.DatFiles/Formats/RomCenter.cs index 9fad6178..c71ed5b5 100644 --- a/SabreTools.DatFiles/Formats/RomCenter.cs +++ b/SabreTools.DatFiles/Formats/RomCenter.cs @@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a RomCenter DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all intenral variables @@ -130,37 +124,37 @@ namespace SabreTools.DatFiles.Formats switch (kvp?.Key.ToLowerInvariant()) { case "author": - Header.Author = Header.Author ?? kvp?.Value; + Header.Author ??= kvp?.Value; reader.ReadNextLine(); break; case "version": - Header.Version = Header.Version ?? kvp?.Value; + Header.Version ??= kvp?.Value; reader.ReadNextLine(); break; case "email": - Header.Email = Header.Email ?? kvp?.Value; + Header.Email ??= kvp?.Value; reader.ReadNextLine(); break; case "homepage": - Header.Homepage = Header.Homepage ?? kvp?.Value; + Header.Homepage ??= kvp?.Value; reader.ReadNextLine(); break; case "url": - Header.Url = Header.Url ?? kvp?.Value; + Header.Url ??= kvp?.Value; reader.ReadNextLine(); break; case "date": - Header.Date = Header.Date ?? kvp?.Value; + Header.Date ??= kvp?.Value; reader.ReadNextLine(); break; case "comment": - Header.Comment = Header.Comment ?? kvp?.Value; + Header.Comment ??= kvp?.Value; reader.ReadNextLine(); break; @@ -205,12 +199,12 @@ namespace SabreTools.DatFiles.Formats switch (kvp?.Key.ToLowerInvariant()) { case "version": - Header.RomCenterVersion = Header.RomCenterVersion ?? kvp?.Value; + Header.RomCenterVersion ??= kvp?.Value; reader.ReadNextLine(); break; case "plugin": - Header.System = Header.System ?? kvp?.Value; + Header.System ??= kvp?.Value; reader.ReadNextLine(); break; @@ -269,12 +263,12 @@ namespace SabreTools.DatFiles.Formats switch (kvp?.Key.ToLowerInvariant()) { case "refname": - Header.Name = Header.Name ?? kvp?.Value; + Header.Name ??= kvp?.Value; reader.ReadNextLine(); break; case "version": - Header.Description = Header.Description ?? kvp?.Value; + Header.Description ??= kvp?.Value; reader.ReadNextLine(); break; @@ -373,13 +367,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/SabreJSON.cs b/SabreTools.DatFiles/Formats/SabreJSON.cs index 1c0cd99b..5e4705c3 100644 --- a/SabreTools.DatFiles/Formats/SabreJSON.cs +++ b/SabreTools.DatFiles/Formats/SabreJSON.cs @@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse a reference JSON DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -332,13 +326,7 @@ namespace SabreTools.DatFiles.Formats } } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/SabreXML.cs b/SabreTools.DatFiles/Formats/SabreXML.cs index 9a6dc390..763b18a5 100644 --- a/SabreTools.DatFiles/Formats/SabreXML.cs +++ b/SabreTools.DatFiles/Formats/SabreXML.cs @@ -24,13 +24,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse an SabreDat XML DAT and return all found directories and files within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -186,13 +180,7 @@ namespace SabreTools.DatFiles.Formats } } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/SeparatedValue.cs b/SabreTools.DatFiles/Formats/SeparatedValue.cs index 10f4817c..a89a1be6 100644 --- a/SabreTools.DatFiles/Formats/SeparatedValue.cs +++ b/SabreTools.DatFiles/Formats/SeparatedValue.cs @@ -31,13 +31,7 @@ namespace SabreTools.DatFiles.Formats _delim = delim; } - /// - /// Parse a character-separated value DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Open a file reader @@ -131,13 +125,7 @@ namespace SabreTools.DatFiles.Formats return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try diff --git a/SabreTools.DatFiles/Formats/SoftwareList.cs b/SabreTools.DatFiles/Formats/SoftwareList.cs index 0ec5727c..f31aa295 100644 --- a/SabreTools.DatFiles/Formats/SoftwareList.cs +++ b/SabreTools.DatFiles/Formats/SoftwareList.cs @@ -90,13 +90,7 @@ namespace SabreTools.DatFiles.Formats { } - /// - /// Parse an SofwareList XML DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// Index ID for the DAT - /// True if full pathnames are to be kept, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise + /// public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) { // Prepare all internal variables @@ -130,8 +124,8 @@ namespace SabreTools.DatFiles.Formats switch (xtr.Name) { case "softwarelist": - Header.Name = Header.Name ?? xtr.GetAttribute("name") ?? string.Empty; - Header.Description = Header.Description ?? xtr.GetAttribute("description") ?? string.Empty; + Header.Name ??= xtr.GetAttribute("name") ?? string.Empty; + Header.Description ??= xtr.GetAttribute("description") ?? string.Empty; xtr.Read(); break; @@ -590,13 +584,7 @@ namespace SabreTools.DatFiles.Formats }; } - /// - /// Create and open an output file for writing direct from a dictionary - /// - /// Name of the file to write to - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if the error that is thrown should be thrown back to the caller, false otherwise - /// True if the DAT was written correctly, false otherwise + /// public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) { try