Allow for blank overrides of header values

This commit is contained in:
Matt Nadareski
2020-08-08 14:06:05 -07:00
parent f27f57855d
commit ff8aebd3f0
13 changed files with 113 additions and 111 deletions

View File

@@ -6,7 +6,6 @@ using System.Text;
using SabreTools.Library.Data; using SabreTools.Library.Data;
using SabreTools.Library.DatItems; using SabreTools.Library.DatItems;
using SabreTools.Library.IO; using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles namespace SabreTools.Library.DatFiles
{ {

View File

@@ -117,48 +117,48 @@ namespace SabreTools.Library.DatFiles
switch (itemKey) switch (itemKey)
{ {
case "name": case "name":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? itemVal : Header.Name); Header.Name = (Header.Name == null ? itemVal : Header.Name);
superdat = superdat || itemVal.Contains(" - SuperDAT"); superdat = superdat || itemVal.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type); Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
break; break;
case "description": case "description":
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? itemVal : Header.Description); Header.Description = (Header.Description == null ? itemVal : Header.Description);
break; break;
case "rootdir": case "rootdir":
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? itemVal : Header.RootDir); Header.RootDir = (Header.RootDir == null ? itemVal : Header.RootDir);
break; break;
case "category": case "category":
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? itemVal : Header.Category); Header.Category = (Header.Category == null ? itemVal : Header.Category);
break; break;
case "version": case "version":
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? itemVal : Header.Version); Header.Version = (Header.Version == null ? itemVal : Header.Version);
break; break;
case "date": case "date":
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? itemVal : Header.Date); Header.Date = (Header.Date == null ? itemVal : Header.Date);
break; break;
case "author": case "author":
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? itemVal : Header.Author); Header.Author = (Header.Author == null ? itemVal : Header.Author);
break; break;
case "email": case "email":
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? itemVal : Header.Email); Header.Email = (Header.Email == null ? itemVal : Header.Email);
break; break;
case "homepage": case "homepage":
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? itemVal : Header.Homepage); Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
break; break;
case "url": case "url":
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? itemVal : Header.Url); Header.Url = (Header.Url == null ? itemVal : Header.Url);
break; break;
case "comment": case "comment":
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? itemVal : Header.Comment); Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
break; break;
case "header": case "header":
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? itemVal : Header.HeaderSkipper); Header.HeaderSkipper = (Header.HeaderSkipper == null ? itemVal : Header.HeaderSkipper);
break; break;
case "type": case "type":
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? itemVal : Header.Type); Header.Type = (Header.Type == null ? itemVal : Header.Type);
superdat = superdat || itemVal.Contains("SuperDAT"); superdat = superdat || itemVal.Contains("SuperDAT");
break; break;
case "forcemerging": case "forcemerging":

View File

@@ -104,18 +104,21 @@ namespace SabreTools.Library.DatFiles
/// <summary> /// <summary>
/// Force a merging style when loaded /// Force a merging style when loaded
/// </summary> /// </summary>
/// TODO: Make nullable
[JsonProperty("forcemerging")] [JsonProperty("forcemerging")]
public ForceMerging ForceMerging { get; set; } public ForceMerging ForceMerging { get; set; }
/// <summary> /// <summary>
/// Force nodump handling when loaded /// Force nodump handling when loaded
/// </summary> /// </summary>
/// TODO: Make nullable
[JsonProperty("forcenodump")] [JsonProperty("forcenodump")]
public ForceNodump ForceNodump { get; set; } public ForceNodump ForceNodump { get; set; }
/// <summary> /// <summary>
/// Force output packing when loaded /// Force output packing when loaded
/// </summary> /// </summary>
/// TODO: Make nullable
[JsonProperty("forcepacking")] [JsonProperty("forcepacking")]
public ForcePacking ForcePacking { get; set; } public ForcePacking ForcePacking { get; set; }

View File

@@ -109,25 +109,25 @@ namespace SabreTools.Library.DatFiles
switch (itemKey) switch (itemKey)
{ {
case "name": case "name":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? itemVal : Header.Name); Header.Name = (Header.Name == null ? itemVal : Header.Name);
break; break;
case "description": case "description":
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? itemVal : Header.Description); Header.Description = (Header.Description == null ? itemVal : Header.Description);
break; break;
case "dersion": case "dersion":
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? itemVal : Header.Version); Header.Version = (Header.Version == null ? itemVal : Header.Version);
break; break;
case "date": case "date":
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? itemVal : Header.Date); Header.Date = (Header.Date == null ? itemVal : Header.Date);
break; break;
case "author": case "author":
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? itemVal : Header.Author); Header.Author = (Header.Author == null ? itemVal : Header.Author);
break; break;
case "homepage": case "homepage":
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? itemVal : Header.Homepage); Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
break; break;
case "comment": case "comment":
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? itemVal : Header.Comment); Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
break; break;
} }
} }

View File

@@ -122,67 +122,67 @@ namespace SabreTools.Library.DatFiles
{ {
case "name": case "name":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? content : Header.Name); Header.Name = (Header.Name == null ? content : Header.Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type); Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
} }
break; break;
case "description": case "description":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description); Header.Description = (Header.Description == null ? content : Header.Description);
break; break;
case "rootdir": // This is exclusive to TruRip XML case "rootdir": // This is exclusive to TruRip XML
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir); Header.RootDir = (Header.RootDir == null ? content : Header.RootDir);
break; break;
case "category": case "category":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category); Header.Category = (Header.Category == null ? content : Header.Category);
break; break;
case "version": case "version":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version); Header.Version = (Header.Version == null ? content : Header.Version);
break; break;
case "date": case "date":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date); Header.Date = (Header.Date == null ? content.Replace(".", "/") : Header.Date);
break; break;
case "author": case "author":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author); Header.Author = (Header.Author == null ? content : Header.Author);
break; break;
case "email": case "email":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? content : Header.Email); Header.Email = (Header.Email == null ? content : Header.Email);
break; break;
case "homepage": case "homepage":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? content : Header.Homepage); Header.Homepage = (Header.Homepage == null ? content : Header.Homepage);
break; break;
case "url": case "url":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? content : Header.Url); Header.Url = (Header.Url == null ? content : Header.Url);
break; break;
case "comment": case "comment":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment); Header.Comment = (Header.Comment == null ? content : Header.Comment);
break; break;
case "type": // This is exclusive to TruRip XML case "type": // This is exclusive to TruRip XML
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? content : Header.Type); Header.Type = (Header.Type == null ? content : Header.Type);
superdat = superdat || content.Contains("SuperDAT"); superdat = superdat || content.Contains("SuperDAT");
break; break;
@@ -206,7 +206,7 @@ namespace SabreTools.Library.DatFiles
case "header": case "header":
content = jtr.ReadAsString(); content = jtr.ReadAsString();
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? content : Header.HeaderSkipper); Header.HeaderSkipper = (Header.HeaderSkipper == null ? content : Header.HeaderSkipper);
break; break;
default: default:

View File

@@ -64,18 +64,18 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name) switch (xtr.Name)
{ {
case "mame": case "mame":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? xtr.GetAttribute("build") : Header.Name); Header.Name = (Header.Name == null ? xtr.GetAttribute("build") : Header.Name);
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? Header.Name : Header.Description); Header.Description = (Header.Description == null ? Header.Name : Header.Description);
// string mame_debug = xtr.GetAttribute("debug"); // (yes|no) "no" string mame_debug = xtr.GetAttribute("debug"); // (yes|no) "no"
// string mame_mameconfig = xtr.GetAttribute("mameconfig"); CDATA string mame_mameconfig = xtr.GetAttribute("mameconfig"); // CDATA
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 = (string.IsNullOrWhiteSpace(Header.Name) ? "M1" : Header.Name); Header.Name = (Header.Name == null ? "M1" : Header.Name);
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? "M1" : Header.Description); Header.Description = (Header.Description == null ? "M1" : Header.Description);
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? xtr.GetAttribute("version") ?? string.Empty : Header.Version); Header.Version = (Header.Version == null ? xtr.GetAttribute("version") ?? string.Empty : Header.Version);
xtr.Read(); xtr.Read();
break; break;

View File

@@ -153,72 +153,72 @@ namespace SabreTools.Library.DatFiles
{ {
case "name": case "name":
content = reader.ReadElementContentAsString(); ; content = reader.ReadElementContentAsString(); ;
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? content : Header.Name); Header.Name = (Header.Name == null ? content : Header.Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type); Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
} }
break; break;
case "description": case "description":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description); Header.Description = (Header.Description == null ? content : Header.Description);
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 = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir); Header.RootDir = (Header.RootDir == null ? content : Header.RootDir);
break; break;
case "category": case "category":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category); Header.Category = (Header.Category == null ? content : Header.Category);
break; break;
case "version": case "version":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version); Header.Version = (Header.Version == null ? content : Header.Version);
break; break;
case "date": case "date":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date); Header.Date = (Header.Date == null ? content.Replace(".", "/") : Header.Date);
break; break;
case "author": case "author":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author); Header.Author = (Header.Author == null ? content : Header.Author);
break; break;
case "email": case "email":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? content : Header.Email); Header.Email = (Header.Email == null ? content : Header.Email);
break; break;
case "homepage": case "homepage":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? content : Header.Homepage); Header.Homepage = (Header.Homepage == null ? content : Header.Homepage);
break; break;
case "url": case "url":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? content : Header.Url); Header.Url = (Header.Url == null ? content : Header.Url);
break; break;
case "comment": case "comment":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment); Header.Comment = (Header.Comment == null ? content : Header.Comment);
break; break;
case "type": // This is exclusive to TruRip XML case "type": // This is exclusive to TruRip XML
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? content : Header.Type); Header.Type = (Header.Type == null ? content : Header.Type);
superdat = superdat || content.Contains("SuperDAT"); superdat = superdat || content.Contains("SuperDAT");
break; break;
case "clrmamepro": case "clrmamepro":
if (string.IsNullOrWhiteSpace(Header.HeaderSkipper)) if (Header.HeaderSkipper == null)
Header.HeaderSkipper = reader.GetAttribute("header"); Header.HeaderSkipper = reader.GetAttribute("header");
if (Header.ForceMerging == ForceMerging.None) if (Header.ForceMerging == ForceMerging.None)

View File

@@ -124,17 +124,17 @@ namespace SabreTools.Library.DatFiles
{ {
case "datname": case "datname":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? content : Header.Name); Header.Name = (Header.Name == null ? content : Header.Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type); Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
} }
break; break;
case "datversion": case "datversion":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version); Header.Version = (Header.Version == null ? content : Header.Version);
break; break;
case "system": case "system":

View File

@@ -61,8 +61,8 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name) switch (xtr.Name)
{ {
case "softwaredb": case "softwaredb":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? "openMSX Software List" : Header.Name); Header.Name = (Header.Name == null ? "openMSX Software List" : Header.Name);
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? Header.Name : Header.Description); Header.Description = (Header.Description == null ? Header.Name : Header.Description);
// string timestamp = xtr.GetAttribute("timestamp"); // CDATA // string timestamp = xtr.GetAttribute("timestamp"); // CDATA
xtr.Read(); xtr.Read();
break; break;

View File

@@ -128,37 +128,37 @@ namespace SabreTools.Library.DatFiles
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "author": case "author":
Header.Author = string.IsNullOrWhiteSpace(Header.Author) ? kvp?.Value : Header.Author; Header.Author = Header.Author == null ? kvp?.Value : Header.Author;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "version": case "version":
Header.Version = string.IsNullOrWhiteSpace(Header.Version) ? kvp?.Value : Header.Version; Header.Version = Header.Version == null ? kvp?.Value : Header.Version;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "email": case "email":
Header.Email = string.IsNullOrWhiteSpace(Header.Email) ? kvp?.Value : Header.Email; Header.Email = Header.Email == null ? kvp?.Value : Header.Email;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "homepage": case "homepage":
Header.Homepage = string.IsNullOrWhiteSpace(Header.Homepage) ? kvp?.Value : Header.Homepage; Header.Homepage = Header.Homepage == null ? kvp?.Value : Header.Homepage;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "url": case "url":
Header.Url = string.IsNullOrWhiteSpace(Header.Url) ? kvp?.Value : Header.Url; Header.Url = Header.Url == null ? kvp?.Value : Header.Url;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "date": case "date":
Header.Date = string.IsNullOrWhiteSpace(Header.Date) ? kvp?.Value : Header.Date; Header.Date = Header.Date == null ? kvp?.Value : Header.Date;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "comment": case "comment":
Header.Comment = string.IsNullOrWhiteSpace(Header.Comment) ? kvp?.Value : Header.Comment; Header.Comment = Header.Comment == null ? kvp?.Value : Header.Comment;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
@@ -265,12 +265,12 @@ namespace SabreTools.Library.DatFiles
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "refname": case "refname":
Header.Name = string.IsNullOrWhiteSpace(Header.Name) ? kvp?.Value : Header.Name; Header.Name = Header.Name == null ? kvp?.Value : Header.Name;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "version": case "version":
Header.Description = string.IsNullOrWhiteSpace(Header.Description) ? kvp?.Value : Header.Description; Header.Description = Header.Description == null ? kvp?.Value : Header.Description;
reader.ReadNextLine(); reader.ReadNextLine();
break; break;

View File

@@ -157,50 +157,50 @@ namespace SabreTools.Library.DatFiles
{ {
case "name": case "name":
content = reader.ReadElementContentAsString(); ; content = reader.ReadElementContentAsString(); ;
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? content : Header.Name); Header.Name = (Header.Name== null ? content : Header.Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type); Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
} }
break; break;
case "description": case "description":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description); Header.Description = (Header.Description== null ? content : Header.Description);
break; break;
case "rootdir": case "rootdir":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir); Header.RootDir = (Header.RootDir== null ? content : Header.RootDir);
break; break;
case "category": case "category":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category); Header.Category = (Header.Category== null ? content : Header.Category);
break; break;
case "version": case "version":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version); Header.Version = (Header.Version== null ? content : Header.Version);
break; break;
case "date": case "date":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date); Header.Date = (Header.Date== null ? content.Replace(".", "/") : Header.Date);
break; break;
case "author": case "author":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author); Header.Author = (Header.Author== null ? content : Header.Author);
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? reader.GetAttribute("email") : Header.Email); Header.Email = (Header.Email == null ? reader.GetAttribute("email") : Header.Email);
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? reader.GetAttribute("homepage") : Header.Homepage); Header.Homepage = (Header.Homepage == null ? reader.GetAttribute("homepage") : Header.Homepage);
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? reader.GetAttribute("url") : Header.Url); Header.Url = (Header.Url == null ? reader.GetAttribute("url") : Header.Url);
break; break;
case "comment": case "comment":
content = reader.ReadElementContentAsString(); content = reader.ReadElementContentAsString();
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment); Header.Comment = (Header.Comment== null ? content : Header.Comment);
break; break;
case "flags": case "flags":
@@ -493,7 +493,7 @@ namespace SabreTools.Library.DatFiles
switch (reader.GetAttribute("name").ToLowerInvariant()) switch (reader.GetAttribute("name").ToLowerInvariant())
{ {
case "type": case "type":
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? content : Header.Type); Header.Type = (Header.Type == null ? content : Header.Type);
superdat = superdat || content.Contains("SuperDAT"); superdat = superdat || content.Contains("SuperDAT");
break; break;

View File

@@ -117,59 +117,59 @@ namespace SabreTools.Library.DatFiles
#region DatFile #region DatFile
case "DatFile.FileName": case "DatFile.FileName":
Header.FileName = (string.IsNullOrWhiteSpace(Header.FileName) ? value : Header.FileName); Header.FileName = (Header.FileName== null ? value : Header.FileName);
break; break;
case "DatFile.Name": case "DatFile.Name":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? value : Header.Name); Header.Name = (Header.Name== null ? value : Header.Name);
break; break;
case "DatFile.Description": case "DatFile.Description":
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? value : Header.Description); Header.Description = (Header.Description== null ? value : Header.Description);
break; break;
case "DatFile.RootDir": case "DatFile.RootDir":
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? value : Header.RootDir); Header.RootDir = (Header.RootDir== null ? value : Header.RootDir);
break; break;
case "DatFile.Category": case "DatFile.Category":
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? value : Header.Category); Header.Category = (Header.Category== null ? value : Header.Category);
break; break;
case "DatFile.Version": case "DatFile.Version":
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? value : Header.Version); Header.Version = (Header.Version== null ? value : Header.Version);
break; break;
case "DatFile.Date": case "DatFile.Date":
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? value : Header.Date); Header.Date = (Header.Date== null ? value : Header.Date);
break; break;
case "DatFile.Author": case "DatFile.Author":
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? value : Header.Author); Header.Author = (Header.Author== null ? value : Header.Author);
break; break;
case "DatFile.Email": case "DatFile.Email":
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? value : Header.Email); Header.Email = (Header.Email== null ? value : Header.Email);
break; break;
case "DatFile.Homepage": case "DatFile.Homepage":
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? value : Header.Homepage); Header.Homepage = (Header.Homepage== null ? value : Header.Homepage);
break; break;
case "DatFile.Url": case "DatFile.Url":
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? value : Header.Url); Header.Url = (Header.Url== null ? value : Header.Url);
break; break;
case "DatFile.Comment": case "DatFile.Comment":
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? value : Header.Comment); Header.Comment = (Header.Comment== null ? value : Header.Comment);
break; break;
case "DatFile.Header": case "DatFile.Header":
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? value : Header.HeaderSkipper); Header.HeaderSkipper = (Header.HeaderSkipper== null ? value : Header.HeaderSkipper);
break; break;
case "DatFile.Type": case "DatFile.Type":
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? value : Header.Type); Header.Type = (Header.Type== null ? value : Header.Type);
break; break;
case "DatFile.ForceMerging": case "DatFile.ForceMerging":
@@ -292,15 +292,15 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.Name": case "DatItem.Name":
name = string.IsNullOrWhiteSpace(value) ? name : value; name = value;
break; break;
case "DatItem.PartName": case "DatItem.PartName":
partName = string.IsNullOrWhiteSpace(value) ? partName : value; partName = value;
break; break;
case "DatItem.PartInterface": case "DatItem.PartInterface":
partInterface = string.IsNullOrWhiteSpace(value) ? partInterface : value; partInterface = value;
break; break;
case "DatItem.Features": case "DatItem.Features":
@@ -315,7 +315,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.AreaName": case "DatItem.AreaName":
areaName = string.IsNullOrWhiteSpace(value) ? areaName : value; areaName = value;
break; break;
case "DatItem.AreaSize": case "DatItem.AreaSize":
@@ -331,7 +331,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.Description": case "DatItem.Description":
biosDescription = string.IsNullOrWhiteSpace(value) ? biosDescription : value; biosDescription = value;
break; break;
case "DatItem.Size": case "DatItem.Size":
@@ -371,15 +371,15 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.Merge": case "DatItem.Merge":
merge = string.IsNullOrWhiteSpace(value) ? merge : value; merge = value;
break; break;
case "DatItem.Region": case "DatItem.Region":
region = string.IsNullOrWhiteSpace(value) ? region : value; region = value;
break; break;
case "DatItem.Index": case "DatItem.Index":
index = string.IsNullOrWhiteSpace(value) ? index : value; index = value;
break; break;
case "DatItem.Writable": case "DatItem.Writable":
@@ -395,7 +395,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.Language": case "DatItem.Language":
language = string.IsNullOrWhiteSpace(value) ? language : value; language = value;
break; break;
case "DatItem.Date": case "DatItem.Date":
@@ -403,11 +403,11 @@ namespace SabreTools.Library.DatFiles
break; break;
case "DatItem.Bios": case "DatItem.Bios":
bios = string.IsNullOrWhiteSpace(value) ? bios : value; bios = value;
break; break;
case "DatItem.Offset": case "DatItem.Offset":
offset = string.IsNullOrWhiteSpace(value) ? offset : value; offset = value;
break; break;
case "DatItem.Inverted": case "DatItem.Inverted":

View File

@@ -62,8 +62,8 @@ namespace SabreTools.Library.DatFiles
switch (xtr.Name) switch (xtr.Name)
{ {
case "softwarelist": case "softwarelist":
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? xtr.GetAttribute("name") ?? string.Empty : Header.Name); Header.Name = (Header.Name == null ? xtr.GetAttribute("name") ?? string.Empty : Header.Name);
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? xtr.GetAttribute("description") ?? string.Empty : Header.Description); Header.Description = (Header.Description == null ? xtr.GetAttribute("description") ?? string.Empty : Header.Description);
if (Header.ForceMerging == ForceMerging.None) if (Header.ForceMerging == ForceMerging.None)
Header.ForceMerging = xtr.GetAttribute("forcemerging").AsForceMerging(); Header.ForceMerging = xtr.GetAttribute("forcemerging").AsForceMerging();