Remove .NET Framework 4.6.2/4.7.2 (#24)

* Remove < .NET 4.8, general cleanup

* Abstract

* Tango

* Banner

* Scan no more

* Common

* Application

* Access

* Filter-feeder

* Graffiti

* Paint-over

* Law and Order

* XOR-o

* Unused staircase

* Maybe

* Maybe not

* Delete this

* The word is "no"

* Emit

* Improper

* Aye aye

* Fence

* Barrier

* Monkey

* Pail

* Lines
This commit is contained in:
Matt Nadareski
2020-07-15 09:41:59 -07:00
committed by GitHub
parent 1a718a3915
commit 4e406604c2
82 changed files with 8975 additions and 11172 deletions

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="datFile">Parent DatFile to copy from</param>
public Json(DatFile datFile)
: base(datFile, cloneHeader: false)
: base(datFile)
{
}
@@ -29,25 +29,18 @@ namespace SabreTools.Library.DatFiles
/// 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="sysid">System ID for the DAT</param>
/// <param name="srcid">Source ID for the DAT</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="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
public override void ParseFile(
protected override void ParseFile(
// Standard Dat parsing
string filename,
int sysid,
int srcid,
int indexId,
// Miscellaneous
bool keep,
bool clean,
bool remUnicode)
bool keep)
{
// Prepare all internal variables
Encoding enc = Utilities.GetEncoding(filename);
StreamReader sr = new StreamReader(Utilities.TryOpenRead(filename), new UTF8Encoding(false));
StreamReader sr = new StreamReader(FileExtensions.TryOpenRead(filename), new UTF8Encoding(false));
JsonTextReader jtr = new JsonTextReader(sr);
// If we got a null reader, just return
@@ -77,7 +70,7 @@ namespace SabreTools.Library.DatFiles
// Machine array
case "machines":
ReadMachines(sr, jtr, clean, remUnicode);
ReadMachines(sr, jtr, filename, indexId);
jtr.Read();
break;
@@ -124,96 +117,96 @@ namespace SabreTools.Library.DatFiles
}
// Get all header items (ONLY OVERWRITE IF THERE'S NO DATA)
string content = string.Empty;
string content;
switch (jtr.Value)
{
case "name":
content = jtr.ReadAsString();
Name = (string.IsNullOrWhiteSpace(Name) ? content : Name);
DatHeader.Name = (string.IsNullOrWhiteSpace(DatHeader.Name) ? content : DatHeader.Name);
superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat)
{
Type = (string.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
DatHeader.Type = (string.IsNullOrWhiteSpace(DatHeader.Type) ? "SuperDAT" : DatHeader.Type);
}
break;
case "description":
content = jtr.ReadAsString();
Description = (string.IsNullOrWhiteSpace(Description) ? content : Description);
DatHeader.Description = (string.IsNullOrWhiteSpace(DatHeader.Description) ? content : DatHeader.Description);
break;
case "rootdir": // This is exclusive to TruRip XML
content = jtr.ReadAsString();
RootDir = (string.IsNullOrWhiteSpace(RootDir) ? content : RootDir);
DatHeader.RootDir = (string.IsNullOrWhiteSpace(DatHeader.RootDir) ? content : DatHeader.RootDir);
break;
case "category":
content = jtr.ReadAsString();
Category = (string.IsNullOrWhiteSpace(Category) ? content : Category);
DatHeader.Category = (string.IsNullOrWhiteSpace(DatHeader.Category) ? content : DatHeader.Category);
break;
case "version":
content = jtr.ReadAsString();
Version = (string.IsNullOrWhiteSpace(Version) ? content : Version);
DatHeader.Version = (string.IsNullOrWhiteSpace(DatHeader.Version) ? content : DatHeader.Version);
break;
case "date":
content = jtr.ReadAsString();
Date = (string.IsNullOrWhiteSpace(Date) ? content.Replace(".", "/") : Date);
DatHeader.Date = (string.IsNullOrWhiteSpace(DatHeader.Date) ? content.Replace(".", "/") : DatHeader.Date);
break;
case "author":
content = jtr.ReadAsString();
Author = (string.IsNullOrWhiteSpace(Author) ? content : Author);
DatHeader.Author = (string.IsNullOrWhiteSpace(DatHeader.Author) ? content : DatHeader.Author);
break;
case "email":
content = jtr.ReadAsString();
Email = (string.IsNullOrWhiteSpace(Email) ? content : Email);
DatHeader.Email = (string.IsNullOrWhiteSpace(DatHeader.Email) ? content : DatHeader.Email);
break;
case "homepage":
content = jtr.ReadAsString();
Homepage = (string.IsNullOrWhiteSpace(Homepage) ? content : Homepage);
DatHeader.Homepage = (string.IsNullOrWhiteSpace(DatHeader.Homepage) ? content : DatHeader.Homepage);
break;
case "url":
content = jtr.ReadAsString();
Url = (string.IsNullOrWhiteSpace(Url) ? content : Url);
DatHeader.Url = (string.IsNullOrWhiteSpace(DatHeader.Url) ? content : DatHeader.Url);
break;
case "comment":
content = jtr.ReadAsString();
Comment = (string.IsNullOrWhiteSpace(Comment) ? content : Comment);
DatHeader.Comment = (string.IsNullOrWhiteSpace(DatHeader.Comment) ? content : DatHeader.Comment);
break;
case "type": // This is exclusive to TruRip XML
content = jtr.ReadAsString();
Type = (string.IsNullOrWhiteSpace(Type) ? content : Type);
DatHeader.Type = (string.IsNullOrWhiteSpace(DatHeader.Type) ? content : DatHeader.Type);
superdat = superdat || content.Contains("SuperDAT");
break;
case "forcemerging":
if (ForceMerging == ForceMerging.None)
ForceMerging = Utilities.GetForceMerging(jtr.ReadAsString());
if (DatHeader.ForceMerging == ForceMerging.None)
DatHeader.ForceMerging = jtr.ReadAsString().AsForceMerging();
break;
case "forcepacking":
if (ForcePacking == ForcePacking.None)
ForcePacking = Utilities.GetForcePacking(jtr.ReadAsString());
if (DatHeader.ForcePacking == ForcePacking.None)
DatHeader.ForcePacking = jtr.ReadAsString().AsForcePacking();
break;
case "forcenodump":
if (ForceNodump == ForceNodump.None)
ForceNodump = Utilities.GetForceNodump(jtr.ReadAsString());
if (DatHeader.ForceNodump == ForceNodump.None)
DatHeader.ForceNodump = jtr.ReadAsString().AsForceNodump();
break;
case "header":
content = jtr.ReadAsString();
Header = (string.IsNullOrWhiteSpace(Header) ? content : Header);
DatHeader.Header = (string.IsNullOrWhiteSpace(DatHeader.Header) ? content : DatHeader.Header);
break;
default:
@@ -229,15 +222,15 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="sr">StreamReader to use to parse the header</param>
/// <param name="itr">JsonTextReader to use to parse the machine</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
private void ReadMachines(
StreamReader sr,
JsonTextReader jtr,
// Miscellaneous
bool clean,
bool remUnicode)
// Standard Dat parsing
string filename,
int indexId)
{
// If the reader is invalid, skip
if (jtr == null)
@@ -257,7 +250,7 @@ namespace SabreTools.Library.DatFiles
continue;
}
ReadMachine(sr, jtr, clean, remUnicode);
ReadMachine(sr, jtr, filename, indexId);
jtr.Read();
}
}
@@ -267,15 +260,15 @@ namespace SabreTools.Library.DatFiles
/// </summary>
/// <param name="sr">StreamReader to use to parse the header</param>
/// <param name="itr">JsonTextReader to use to parse the machine</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
private void ReadMachine(
StreamReader sr,
JsonTextReader jtr,
// Miscellaneous
bool clean,
bool remUnicode)
// Standard Dat parsing
string filename,
int indexId)
{
// If we have an empty machine, skip it
if (jtr == null)
@@ -337,19 +330,7 @@ namespace SabreTools.Library.DatFiles
break;
case "supported":
string supported = jtr.ReadAsString();
switch (supported)
{
case "yes":
machine.Supported = true;
break;
case "no":
machine.Supported = false;
break;
case "partial":
machine.Supported = null;
break;
}
machine.Supported = jtr.ReadAsString().AsYesNo();
break;
case "sourcefile":
@@ -357,16 +338,7 @@ namespace SabreTools.Library.DatFiles
break;
case "runnable":
string runnable = jtr.ReadAsString();
switch (runnable)
{
case "yes":
machine.Runnable = true;
break;
case "no":
machine.Runnable = false;
break;
}
machine.Runnable = jtr.ReadAsString().AsYesNo();
break;
case "board":
@@ -438,7 +410,7 @@ namespace SabreTools.Library.DatFiles
break;
case "items":
ReadItems(sr, jtr, clean, remUnicode, machine);
ReadItems(sr, jtr, filename, indexId, machine);
break;
default:
@@ -453,16 +425,19 @@ namespace SabreTools.Library.DatFiles
/// Read item array information
/// </summary>
/// <param name="sr">StreamReader to use to parse the header</param>
/// <param name="itr">JsonTextReader to use to parse the machine</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="jtr">JsonTextReader to use to parse the machine</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="machine">Machine information to add to the parsed items</param>
private void ReadItems(
StreamReader sr,
JsonTextReader jtr,
// Standard Dat parsing
string filename,
int indexId,
// Miscellaneous
bool clean,
bool remUnicode,
Machine machine)
{
// If the reader is invalid, skip
@@ -483,7 +458,7 @@ namespace SabreTools.Library.DatFiles
continue;
}
ReadItem(sr, jtr, clean, remUnicode, machine);
ReadItem(sr, jtr, filename, indexId, machine);
jtr.Read();
}
}
@@ -492,16 +467,19 @@ namespace SabreTools.Library.DatFiles
/// Read item information
/// </summary>
/// <param name="sr">StreamReader to use to parse the header</param>
/// <param name="itr">JsonTextReader to use to parse the machine</param>
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="jtr">JsonTextReader to use to parse the machine</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
/// <param name="machine">Machine information to add to the parsed items</param>
private void ReadItem(
StreamReader sr,
JsonTextReader jtr,
// Standard Dat parsing
string filename,
int indexId,
// Miscellaneous
bool clean,
bool remUnicode,
Machine machine)
{
// If we have an empty machine, skip it
@@ -547,8 +525,10 @@ namespace SabreTools.Library.DatFiles
if (itemType == null)
return;
DatItem datItem = Utilities.GetDatItem(itemType.Value);
DatItem datItem = DatItem.Create(itemType.Value);
datItem.CopyMachineInformation(machine);
datItem.IndexId = indexId;
datItem.IndexSource = filename;
datItem.Name = name;
datItem.PartName = partName;
@@ -565,7 +545,9 @@ namespace SabreTools.Library.DatFiles
else if (itemType == ItemType.Disk)
{
(datItem as Disk).MD5 = md5;
#if NET_FRAMEWORK
(datItem as Disk).RIPEMD160 = ripemd160;
#endif
(datItem as Disk).SHA1 = sha1;
(datItem as Disk).SHA256 = sha256;
(datItem as Disk).SHA384 = sha384;
@@ -590,7 +572,9 @@ namespace SabreTools.Library.DatFiles
(datItem as Rom).Size = size;
(datItem as Rom).CRC = crc;
(datItem as Rom).MD5 = md5;
#if NET_FRAMEWORK
(datItem as Rom).RIPEMD160 = ripemd160;
#endif
(datItem as Rom).SHA1 = sha1;
(datItem as Rom).SHA256 = sha256;
(datItem as Rom).SHA384 = sha384;
@@ -603,7 +587,7 @@ namespace SabreTools.Library.DatFiles
(datItem as Rom).Optional = optional;
}
ParseAddHelper(datItem, clean, remUnicode);
ParseAddHelper(datItem);
return;
}
@@ -618,7 +602,7 @@ namespace SabreTools.Library.DatFiles
switch (jtr.Value)
{
case "type":
itemType = Utilities.GetItemType(jtr.ReadAsString());
itemType = jtr.ReadAsString().AsItemType();
break;
case "name":
@@ -731,7 +715,7 @@ namespace SabreTools.Library.DatFiles
break;
case "status":
itemStatus = Utilities.GetItemStatus(jtr.ReadAsString());
itemStatus = jtr.ReadAsString().AsItemStatus();
break;
case "optional":
@@ -765,7 +749,7 @@ namespace SabreTools.Library.DatFiles
try
{
Globals.Logger.User($"Opening file for writing: {outfile}");
FileStream fs = Utilities.TryCreate(outfile);
FileStream fs = FileExtensions.TryCreate(outfile);
// If we get back null for some reason, just log and return
if (fs == null)
@@ -775,10 +759,12 @@ namespace SabreTools.Library.DatFiles
}
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
JsonTextWriter jtw = new JsonTextWriter(sw);
jtw.Formatting = Formatting.Indented;
jtw.IndentChar = '\t';
jtw.Indentation = 1;
JsonTextWriter jtw = new JsonTextWriter(sw)
{
Formatting = Formatting.Indented,
IndentChar = '\t',
Indentation = 1
};
// Write out the header
WriteHeader(jtw);
@@ -827,7 +813,9 @@ namespace SabreTools.Library.DatFiles
((Rom)rom).Size = Constants.SizeZero;
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
#if NET_FRAMEWORK
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
#endif
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
@@ -873,57 +861,57 @@ namespace SabreTools.Library.DatFiles
jtw.WriteStartObject();
jtw.WritePropertyName("name");
jtw.WriteValue(Name);
jtw.WriteValue(DatHeader.Name);
jtw.WritePropertyName("description");
jtw.WriteValue(Description);
if (!string.IsNullOrWhiteSpace(RootDir))
jtw.WriteValue(DatHeader.Description);
if (!string.IsNullOrWhiteSpace(DatHeader.RootDir))
{
jtw.WritePropertyName("rootdir");
jtw.WriteValue(RootDir);
jtw.WriteValue(DatHeader.RootDir);
}
if (!string.IsNullOrWhiteSpace(Category))
if (!string.IsNullOrWhiteSpace(DatHeader.Category))
{
jtw.WritePropertyName("category");
jtw.WriteValue(Category);
jtw.WriteValue(DatHeader.Category);
}
jtw.WritePropertyName("version");
jtw.WriteValue(Version);
if (!string.IsNullOrWhiteSpace(Date))
jtw.WriteValue(DatHeader.Version);
if (!string.IsNullOrWhiteSpace(DatHeader.Date))
{
jtw.WritePropertyName("date");
jtw.WriteValue(Date);
jtw.WriteValue(DatHeader.Date);
}
jtw.WritePropertyName("author");
jtw.WriteValue(Author);
if (!string.IsNullOrWhiteSpace(Email))
jtw.WriteValue(DatHeader.Author);
if (!string.IsNullOrWhiteSpace(DatHeader.Email))
{
jtw.WritePropertyName("email");
jtw.WriteValue(Email);
jtw.WriteValue(DatHeader.Email);
}
if (!string.IsNullOrWhiteSpace(Homepage))
if (!string.IsNullOrWhiteSpace(DatHeader.Homepage))
{
jtw.WritePropertyName("homepage");
jtw.WriteValue(Homepage);
jtw.WriteValue(DatHeader.Homepage);
}
if (!string.IsNullOrWhiteSpace(Url))
if (!string.IsNullOrWhiteSpace(DatHeader.Url))
{
jtw.WritePropertyName("date");
jtw.WriteValue(Url);
jtw.WriteValue(DatHeader.Url);
}
if (!string.IsNullOrWhiteSpace(Comment))
if (!string.IsNullOrWhiteSpace(DatHeader.Comment))
{
jtw.WritePropertyName("comment");
jtw.WriteValue(Comment);
jtw.WriteValue(DatHeader.Comment);
}
if (!string.IsNullOrWhiteSpace(Type))
if (!string.IsNullOrWhiteSpace(DatHeader.Type))
{
jtw.WritePropertyName("type");
jtw.WriteValue(Type);
jtw.WriteValue(DatHeader.Type);
}
if (ForceMerging != ForceMerging.None)
if (DatHeader.ForceMerging != ForceMerging.None)
{
jtw.WritePropertyName("forcemerging");
switch (ForceMerging)
switch (DatHeader.ForceMerging)
{
case ForceMerging.Full:
jtw.WriteValue("full");
@@ -939,10 +927,10 @@ namespace SabreTools.Library.DatFiles
break;
}
}
if (ForcePacking != ForcePacking.None)
if (DatHeader.ForcePacking != ForcePacking.None)
{
jtw.WritePropertyName("forcepacking");
switch (ForcePacking)
switch (DatHeader.ForcePacking)
{
case ForcePacking.Unzip:
jtw.WriteValue("unzip");
@@ -952,10 +940,10 @@ namespace SabreTools.Library.DatFiles
break;
}
}
if (ForceNodump != ForceNodump.None)
if (DatHeader.ForceNodump != ForceNodump.None)
{
jtw.WritePropertyName("forcenodump");
switch (ForceNodump)
switch (DatHeader.ForceNodump)
{
case ForceNodump.Ignore:
jtw.WriteValue("ignore");
@@ -968,10 +956,10 @@ namespace SabreTools.Library.DatFiles
break;
}
}
if (!string.IsNullOrWhiteSpace(Header))
if (!string.IsNullOrWhiteSpace(DatHeader.Header))
{
jtw.WritePropertyName("header");
jtw.WriteValue(Header);
jtw.WriteValue(DatHeader.Header);
}
// End header
@@ -1008,49 +996,49 @@ namespace SabreTools.Library.DatFiles
jtw.WriteStartObject();
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.MachineName, ExcludeFields));
jtw.WriteValue(datItem.GetField(Field.MachineName, DatHeader.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("comment");
jtw.WriteValue(datItem.Comment);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("description");
jtw.WriteValue(datItem.MachineDescription);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("year");
jtw.WriteValue(datItem.Year);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("manufacturer");
jtw.WriteValue(datItem.Manufacturer);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("publisher");
jtw.WriteValue(datItem.Publisher);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, DatHeader.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("romof");
jtw.WriteValue(datItem.RomOf);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, DatHeader.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("cloneof");
jtw.WriteValue(datItem.CloneOf);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.SampleOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, DatHeader.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.SampleOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("sampleof");
jtw.WriteValue(datItem.SampleOf);
}
if (!ExcludeFields[(int)Field.Supported] && datItem.Supported != null)
if (!DatHeader.ExcludeFields[(int)Field.Supported] && datItem.Supported != null)
{
if (datItem.Supported == true)
{
@@ -1063,12 +1051,12 @@ namespace SabreTools.Library.DatFiles
jtw.WriteValue("no");
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sourcefile");
jtw.WriteValue(datItem.SourceFile);
}
if (!ExcludeFields[(int)Field.Runnable] && datItem.Runnable != null)
if (!DatHeader.ExcludeFields[(int)Field.Runnable] && datItem.Runnable != null)
{
if (datItem.Runnable == true)
{
@@ -1081,17 +1069,17 @@ namespace SabreTools.Library.DatFiles
jtw.WriteValue("no");
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("board");
jtw.WriteValue(datItem.Board);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("rebuildto");
jtw.WriteValue(datItem.RebuildTo);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Devices, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Devices, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("devices");
jtw.WriteStartArray();
@@ -1102,7 +1090,7 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SlotOptions, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SlotOptions, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("slotoptions");
jtw.WriteStartArray();
@@ -1113,7 +1101,7 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Infos, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Infos, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("infos");
jtw.WriteStartArray();
@@ -1127,19 +1115,19 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!ExcludeFields[(int)Field.MachineType])
if (!DatHeader.ExcludeFields[(int)Field.MachineType])
{
if ((datItem.MachineType & MachineType.Bios) != 0)
if (datItem.MachineType.HasFlag(MachineType.Bios))
{
jtw.WritePropertyName("isbios");
jtw.WriteValue("yes");
}
if ((datItem.MachineType & MachineType.Device) != 0)
if (datItem.MachineType.HasFlag(MachineType.Device))
{
jtw.WritePropertyName("isdevice");
jtw.WriteValue("yes");
}
if ((datItem.MachineType & MachineType.Mechanical) != 0)
if (datItem.MachineType.HasFlag(MachineType.Mechanical))
{
jtw.WritePropertyName("ismechanical");
jtw.WriteValue("yes");
@@ -1217,20 +1205,20 @@ namespace SabreTools.Library.DatFiles
case ItemType.Archive:
jtw.WriteValue("archive");
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.Name, ExcludeFields));
jtw.WriteValue(datItem.GetField(Field.Name, DatHeader.ExcludeFields));
break;
case ItemType.BiosSet:
var biosSet = datItem as BiosSet;
jtw.WriteValue("biosset");
jtw.WritePropertyName("name");
jtw.WriteValue(biosSet.GetField(Field.Name, ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, ExcludeFields)))
jtw.WriteValue(biosSet.GetField(Field.Name, DatHeader.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("description");
jtw.WriteValue(biosSet.Description);
}
if (!ExcludeFields[(int)Field.Default] && biosSet.Default != null)
if (!DatHeader.ExcludeFields[(int)Field.Default] && biosSet.Default != null)
{
jtw.WritePropertyName("default");
jtw.WriteValue(biosSet.Default);
@@ -1241,63 +1229,65 @@ namespace SabreTools.Library.DatFiles
var disk = datItem as Disk;
jtw.WriteValue("disk");
jtw.WritePropertyName("name");
jtw.WriteValue(disk.GetField(Field.Name, ExcludeFields));
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.MD5, ExcludeFields)))
jtw.WriteValue(disk.GetField(Field.Name, DatHeader.ExcludeFields));
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.MD5, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("md5");
jtw.WriteValue(disk.MD5.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.MD5, ExcludeFields)))
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.RIPEMD160, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("ripemd160");
jtw.WriteValue(disk.RIPEMD160.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA1, ExcludeFields)))
#endif
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA1, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha1");
jtw.WriteValue(disk.SHA1.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA256, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA256, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha256");
jtw.WriteValue(disk.SHA256.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA384, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA384, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha384");
jtw.WriteValue(disk.SHA384.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA512, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA512, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha512");
jtw.WriteValue(disk.SHA512.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Merge, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Merge, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("merge");
jtw.WriteValue(disk.MergeTag);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Region, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Region, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("region");
jtw.WriteValue(disk.Region);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Index, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Index, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("index");
jtw.WriteValue(disk.Index);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Writable, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Writable, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("writable");
jtw.WriteValue(disk.Writable);
}
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
if (!DatHeader.ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
{
jtw.WritePropertyName("status");
jtw.WriteValue(disk.ItemStatus.ToString().ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Optional, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Optional, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("optional");
jtw.WriteValue(disk.Optional);
@@ -1308,23 +1298,23 @@ namespace SabreTools.Library.DatFiles
var release = datItem as Release;
jtw.WriteValue("release");
jtw.WritePropertyName("name");
jtw.WriteValue(release.GetField(Field.Name, ExcludeFields));
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Region, ExcludeFields)))
jtw.WriteValue(release.GetField(Field.Name, DatHeader.ExcludeFields));
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Region, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("region");
jtw.WriteValue(release.Region);
}
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Language, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Language, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("language");
jtw.WriteValue(release.Language);
}
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Date, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Date, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("date");
jtw.WriteValue(release.Date);
}
if (!ExcludeFields[(int)Field.Default] && release.Default != null)
if (!DatHeader.ExcludeFields[(int)Field.Default] && release.Default != null)
{
jtw.WritePropertyName("default");
jtw.WriteValue(release.Default);
@@ -1335,78 +1325,80 @@ namespace SabreTools.Library.DatFiles
var rom = datItem as Rom;
jtw.WriteValue("rom");
jtw.WritePropertyName("name");
jtw.WriteValue(rom.GetField(Field.Name, ExcludeFields));
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
jtw.WriteValue(rom.GetField(Field.Name, DatHeader.ExcludeFields));
if (!DatHeader.ExcludeFields[(int)Field.Size] && rom.Size != -1)
{
jtw.WritePropertyName("size");
jtw.WriteValue(rom.Size);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Offset, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Offset, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("offset");
jtw.WriteValue(rom.Offset);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.CRC, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.CRC, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("crc");
jtw.WriteValue(rom.CRC.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.MD5, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.MD5, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("md5");
jtw.WriteValue(rom.MD5.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.MD5, ExcludeFields)))
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.RIPEMD160, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("ripemd160");
jtw.WriteValue(rom.RIPEMD160.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA1, ExcludeFields)))
#endif
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA1, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha1");
jtw.WriteValue(rom.SHA1.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA256, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA256, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha256");
jtw.WriteValue(rom.SHA256.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA384, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA384, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha384");
jtw.WriteValue(rom.SHA384.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA512, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA512, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("sha512");
jtw.WriteValue(rom.SHA512.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Bios, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Bios, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("bios");
jtw.WriteValue(rom.Bios);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Merge, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Merge, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("merge");
jtw.WriteValue(rom.MergeTag);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Region, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Region, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("region");
jtw.WriteValue(rom.Region);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Date, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Date, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("date");
jtw.WriteValue(rom.Date);
}
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
if (!DatHeader.ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
{
jtw.WritePropertyName("status");
jtw.WriteValue(rom.ItemStatus.ToString().ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Optional, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Optional, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("optional");
jtw.WriteValue(rom.Optional);
@@ -1416,21 +1408,21 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample:
jtw.WriteValue("sample");
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.Name, ExcludeFields));
jtw.WriteValue(datItem.GetField(Field.Name, DatHeader.ExcludeFields));
break;
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartName, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartName, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("partname");
jtw.WriteValue(datItem.PartName);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartInterface, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartInterface, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("partinterface");
jtw.WriteValue(datItem.PartInterface);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Features, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Features, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("features");
jtw.WriteStartArray();
@@ -1444,12 +1436,12 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaName, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaName, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("areaname");
jtw.WriteValue(datItem.AreaName);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaSize, ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaSize, DatHeader.ExcludeFields)))
{
jtw.WritePropertyName("areasize");
jtw.WriteValue(datItem.AreaSize);