Compound assignments and inheritdoc for DatFiles

This commit is contained in:
Matt Nadareski
2020-12-18 12:09:09 -08:00
parent 7bbdb22948
commit d741c8d4b2
17 changed files with 104 additions and 296 deletions

View File

@@ -12,8 +12,8 @@ namespace SabreTools.Core
/// <summary> /// <summary>
/// The current toolset version to be used by all child applications /// The current toolset version to be used by all child applications
/// </summary> /// </summary>
public readonly static string Version = $"v1.0.6"; //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-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
/// <summary> /// <summary>
/// Readies the console and outputs the header /// Readies the console and outputs the header

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse an AttractMode DAT and return all found games within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -123,13 +117,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -37,13 +37,7 @@ namespace SabreTools.DatFiles.Formats
Quotes = quotes; Quotes = quotes;
} }
/// <summary> /// <inheritdoc/>
/// Parse a ClrMamePro DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -139,49 +133,49 @@ namespace SabreTools.DatFiles.Formats
switch (itemKey) switch (itemKey)
{ {
case "name": case "name":
Header.Name = Header.Name ?? itemVal; Header.Name ??= itemVal;
superdat = superdat || itemVal.Contains(" - SuperDAT"); superdat |= itemVal.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
Header.Type = Header.Type ?? "SuperDAT"; Header.Type ??= "SuperDAT";
break; break;
case "description": case "description":
Header.Description = Header.Description ?? itemVal; Header.Description ??= itemVal;
break; break;
case "rootdir": case "rootdir":
Header.RootDir = Header.RootDir ?? itemVal; Header.RootDir ??= itemVal;
break; break;
case "category": case "category":
Header.Category = Header.Category ?? itemVal; Header.Category ??= itemVal;
break; break;
case "version": case "version":
Header.Version = Header.Version ?? itemVal; Header.Version ??= itemVal;
break; break;
case "date": case "date":
Header.Date = Header.Date ?? itemVal; Header.Date ??= itemVal;
break; break;
case "author": case "author":
Header.Author = Header.Author ?? itemVal; Header.Author ??= itemVal;
break; break;
case "email": case "email":
Header.Email = Header.Email ?? itemVal; Header.Email ??= itemVal;
break; break;
case "homepage": case "homepage":
Header.Homepage = Header.Homepage ?? itemVal; Header.Homepage ??= itemVal;
break; break;
case "url": case "url":
Header.Url = Header.Url ?? itemVal; Header.Url ??= itemVal;
break; break;
case "comment": case "comment":
Header.Comment = Header.Comment ?? itemVal; Header.Comment ??= itemVal;
break; break;
case "header": case "header":
Header.HeaderSkipper = Header.HeaderSkipper ?? itemVal; Header.HeaderSkipper ??= itemVal;
break; break;
case "type": case "type":
Header.Type = Header.Type ?? itemVal; Header.Type ??= itemVal;
superdat = superdat || itemVal.Contains("SuperDAT"); superdat |= itemVal.Contains("SuperDAT");
break; break;
case "forcemerging": case "forcemerging":
if (Header.ForceMerging == MergingFlag.None) if (Header.ForceMerging == MergingFlag.None)
@@ -442,13 +436,7 @@ namespace SabreTools.DatFiles.Formats
}; };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a DOSCenter DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -119,25 +113,25 @@ namespace SabreTools.DatFiles.Formats
switch (itemKey) switch (itemKey)
{ {
case "name": case "name":
Header.Name = Header.Name ?? itemVal; Header.Name ??= itemVal;
break; break;
case "description": case "description":
Header.Description = Header.Description ?? itemVal; Header.Description ??= itemVal;
break; break;
case "dersion": case "dersion":
Header.Version = Header.Version ?? itemVal; Header.Version ??= itemVal;
break; break;
case "date": case "date":
Header.Date = Header.Date ?? itemVal; Header.Date ??= itemVal;
break; break;
case "author": case "author":
Header.Author = Header.Author ?? itemVal; Header.Author ??= itemVal;
break; break;
case "homepage": case "homepage":
Header.Homepage = Header.Homepage ?? itemVal; Header.Homepage ??= itemVal;
break; break;
case "comment": case "comment":
Header.Comment = Header.Comment ?? itemVal; Header.Comment ??= itemVal;
break; break;
} }
} }
@@ -268,13 +262,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse an Everdrive SMDB file and return all found games within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -114,13 +108,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -29,13 +29,7 @@ namespace SabreTools.DatFiles.Formats
_hash = hash; _hash = hash;
} }
/// <summary> /// <inheritdoc/>
/// Parse a hashfile or SFV and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -115,13 +109,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a MAME Listrom DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <remarks> /// <remarks>
/// In a new style MAME listrom DAT, each game has the following format: /// 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 }; return new ItemType[] { ItemType.Disk, ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -190,13 +190,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a MAME XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -230,18 +224,18 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name) switch (xtr.Name)
{ {
case "mame": case "mame":
Header.Name = Header.Name ?? xtr.GetAttribute("build"); Header.Name ??= xtr.GetAttribute("build");
Header.Description = Header.Description ?? Header.Name; Header.Description ??= Header.Name;
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo(); Header.Debug ??= xtr.GetAttribute("debug").AsYesNo();
Header.MameConfig = Header.MameConfig ?? xtr.GetAttribute("mameconfig"); Header.MameConfig ??= xtr.GetAttribute("mameconfig");
xtr.Read(); xtr.Read();
break; break;
// Handle M1 DATs since they're 99% the same as a SL DAT // Handle M1 DATs since they're 99% the same as a SL DAT
case "m1": case "m1":
Header.Name = Header.Name ?? "M1"; Header.Name ??= "M1";
Header.Description = Header.Description ?? "M1"; Header.Description ??= "M1";
Header.Version = Header.Version ?? xtr.GetAttribute("version") ?? string.Empty; Header.Version ??= xtr.GetAttribute("version") ?? string.Empty;
xtr.Read(); xtr.Read();
break; break;
@@ -1352,13 +1346,7 @@ namespace SabreTools.DatFiles.Formats
}; };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -132,13 +132,7 @@ namespace SabreTools.DatFiles.Formats
_deprecated = deprecated; _deprecated = deprecated;
} }
/// <summary> /// <inheritdoc/>
/// Parse a Logiqx XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -179,8 +173,8 @@ namespace SabreTools.DatFiles.Formats
{ {
// The datafile tag can have some attributes // The datafile tag can have some attributes
case "datafile": case "datafile":
Header.Build = Header.Build ?? xtr.GetAttribute("build"); Header.Build ??= xtr.GetAttribute("build");
Header.Debug = Header.Debug ?? xtr.GetAttribute("debug").AsYesNo(); Header.Debug ??= xtr.GetAttribute("debug").AsYesNo();
xtr.Read(); xtr.Read();
break; break;
@@ -261,57 +255,57 @@ namespace SabreTools.DatFiles.Formats
{ {
case "name": case "name":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Name = Header.Name ?? content; Header.Name ??= content;
superdat = superdat || content.Contains(" - SuperDAT"); superdat |= content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = Header.Type ?? "SuperDAT"; Header.Type ??= "SuperDAT";
} }
break; break;
case "description": case "description":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Description = Header.Description ?? content; Header.Description ??= content;
break; break;
case "rootdir": // This is exclusive to TruRip XML case "rootdir": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.RootDir = Header.RootDir ?? content; Header.RootDir ??= content;
break; break;
case "category": case "category":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Category = Header.Category ?? content; Header.Category ??= content;
break; break;
case "version": case "version":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Version = Header.Version ?? content; Header.Version ??= content;
break; break;
case "date": case "date":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Date = Header.Date ?? content.Replace(".", "/"); Header.Date ??= content.Replace(".", "/");
break; break;
case "author": case "author":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Author = Header.Author ?? content; Header.Author ??= content;
break; break;
case "email": case "email":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Email = Header.Email ?? content; Header.Email ??= content;
break; break;
case "homepage": case "homepage":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Homepage = Header.Homepage ?? content; Header.Homepage ??= content;
break; break;
case "url": case "url":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Url = Header.Url ?? content; Header.Url ??= content;
break; break;
case "comment": case "comment":
@@ -321,8 +315,8 @@ namespace SabreTools.DatFiles.Formats
case "type": // This is exclusive to TruRip XML case "type": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Type = Header.Type ?? content; Header.Type ??= content;
superdat = superdat || content.Contains("SuperDAT"); superdat |= content.Contains("SuperDAT");
break; break;
case "clrmamepro": case "clrmamepro":
@@ -781,13 +775,7 @@ namespace SabreTools.DatFiles.Formats
}; };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -21,26 +21,14 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a Missfile and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// There is no consistent way to parse a missfile... // There is no consistent way to parse a missfile...
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -26,13 +26,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse an OfflineList XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
@@ -132,34 +126,34 @@ namespace SabreTools.DatFiles.Formats
{ {
case "datname": case "datname":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Name = Header.Name ?? content; Header.Name ??= content;
superdat = superdat || content.Contains(" - SuperDAT"); superdat |= content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = Header.Type ?? "SuperDAT"; Header.Type ??= "SuperDAT";
} }
break; break;
case "datversion": case "datversion":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Version = Header.Version ?? content; Header.Version ??= content;
break; break;
case "system": case "system":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.System = Header.System ?? content; Header.System ??= content;
break; break;
// TODO: Int32? // TODO: Int32?
case "screenshotswidth": case "screenshotswidth":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.ScreenshotsWidth = Header.ScreenshotsWidth ?? content; Header.ScreenshotsWidth ??= content;
break; break;
// TODO: Int32? // TODO: Int32?
case "screenshotsheight": case "screenshotsheight":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.ScreenshotsHeight = Header.ScreenshotsHeight ?? content; Header.ScreenshotsHeight ??= content;
break; break;
case "infos": case "infos":
@@ -194,7 +188,7 @@ namespace SabreTools.DatFiles.Formats
case "romtitle": case "romtitle":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.RomTitle = Header.RomTitle ?? content; Header.RomTitle ??= content;
break; break;
default: default:
@@ -674,13 +668,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -40,13 +40,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a openMSX softawre list XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -80,9 +74,9 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name) switch (xtr.Name)
{ {
case "softwaredb": case "softwaredb":
Header.Name = Header.Name ?? "openMSX Software List"; Header.Name ??= "openMSX Software List";
Header.Description = Header.Description ?? Header.Name; Header.Description ??= Header.Name;
Header.Date = Header.Date ?? xtr.GetAttribute("timestamp"); Header.Date ??= xtr.GetAttribute("timestamp");
xtr.Read(); xtr.Read();
break; break;
@@ -542,13 +536,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -25,13 +25,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a RomCenter DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all intenral variables // Prepare all intenral variables
@@ -130,37 +124,37 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "author": case "author":
Header.Author = Header.Author ?? kvp?.Value; Header.Author ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "version": case "version":
Header.Version = Header.Version ?? kvp?.Value; Header.Version ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "email": case "email":
Header.Email = Header.Email ?? kvp?.Value; Header.Email ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "homepage": case "homepage":
Header.Homepage = Header.Homepage ?? kvp?.Value; Header.Homepage ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "url": case "url":
Header.Url = Header.Url ?? kvp?.Value; Header.Url ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "date": case "date":
Header.Date = Header.Date ?? kvp?.Value; Header.Date ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "comment": case "comment":
Header.Comment = Header.Comment ?? kvp?.Value; Header.Comment ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
@@ -205,12 +199,12 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "version": case "version":
Header.RomCenterVersion = Header.RomCenterVersion ?? kvp?.Value; Header.RomCenterVersion ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "plugin": case "plugin":
Header.System = Header.System ?? kvp?.Value; Header.System ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
@@ -269,12 +263,12 @@ namespace SabreTools.DatFiles.Formats
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "refname": case "refname":
Header.Name = Header.Name ?? kvp?.Value; Header.Name ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "version": case "version":
Header.Description = Header.Description ?? kvp?.Value; Header.Description ??= kvp?.Value;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
@@ -373,13 +367,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Rom }; return new ItemType[] { ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -27,13 +27,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse a reference JSON DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -332,13 +326,7 @@ namespace SabreTools.DatFiles.Formats
} }
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -24,13 +24,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse an SabreDat XML DAT and return all found directories and files within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -186,13 +180,7 @@ namespace SabreTools.DatFiles.Formats
} }
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -31,13 +31,7 @@ namespace SabreTools.DatFiles.Formats
_delim = delim; _delim = delim;
} }
/// <summary> /// <inheritdoc/>
/// Parse a character-separated value DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Open a file reader // Open a file reader
@@ -131,13 +125,7 @@ namespace SabreTools.DatFiles.Formats
return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom }; return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try

View File

@@ -90,13 +90,7 @@ namespace SabreTools.DatFiles.Formats
{ {
} }
/// <summary> /// <inheritdoc/>
/// Parse an SofwareList XML DAT and return all found games and roms within
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false) public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
{ {
// Prepare all internal variables // Prepare all internal variables
@@ -130,8 +124,8 @@ namespace SabreTools.DatFiles.Formats
switch (xtr.Name) switch (xtr.Name)
{ {
case "softwarelist": case "softwarelist":
Header.Name = Header.Name ?? xtr.GetAttribute("name") ?? string.Empty; Header.Name ??= xtr.GetAttribute("name") ?? string.Empty;
Header.Description = Header.Description ?? xtr.GetAttribute("description") ?? string.Empty; Header.Description ??= xtr.GetAttribute("description") ?? string.Empty;
xtr.Read(); xtr.Read();
break; break;
@@ -590,13 +584,7 @@ namespace SabreTools.DatFiles.Formats
}; };
} }
/// <summary> /// <inheritdoc/>
/// Create and open an output file for writing direct from a dictionary
/// </summary>
/// <param name="outfile">Name of the file to write to</param>
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns>
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false) public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{ {
try try