mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Allow for blank overrides of header values
This commit is contained in:
@@ -6,7 +6,6 @@ using System.Text;
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
using SabreTools.Library.IO;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
|
||||
@@ -117,48 +117,48 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (itemKey)
|
||||
{
|
||||
case "name":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? itemVal : Header.Name);
|
||||
Header.Name = (Header.Name == null ? itemVal : Header.Name);
|
||||
superdat = superdat || itemVal.Contains(" - SuperDAT");
|
||||
|
||||
if (keep && superdat)
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type);
|
||||
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
|
||||
|
||||
break;
|
||||
case "description":
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? itemVal : Header.Description);
|
||||
Header.Description = (Header.Description == null ? itemVal : Header.Description);
|
||||
break;
|
||||
case "rootdir":
|
||||
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? itemVal : Header.RootDir);
|
||||
Header.RootDir = (Header.RootDir == null ? itemVal : Header.RootDir);
|
||||
break;
|
||||
case "category":
|
||||
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? itemVal : Header.Category);
|
||||
Header.Category = (Header.Category == null ? itemVal : Header.Category);
|
||||
break;
|
||||
case "version":
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? itemVal : Header.Version);
|
||||
Header.Version = (Header.Version == null ? itemVal : Header.Version);
|
||||
break;
|
||||
case "date":
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? itemVal : Header.Date);
|
||||
Header.Date = (Header.Date == null ? itemVal : Header.Date);
|
||||
break;
|
||||
case "author":
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? itemVal : Header.Author);
|
||||
Header.Author = (Header.Author == null ? itemVal : Header.Author);
|
||||
break;
|
||||
case "email":
|
||||
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? itemVal : Header.Email);
|
||||
Header.Email = (Header.Email == null ? itemVal : Header.Email);
|
||||
break;
|
||||
case "homepage":
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? itemVal : Header.Homepage);
|
||||
Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
|
||||
break;
|
||||
case "url":
|
||||
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? itemVal : Header.Url);
|
||||
Header.Url = (Header.Url == null ? itemVal : Header.Url);
|
||||
break;
|
||||
case "comment":
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? itemVal : Header.Comment);
|
||||
Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
|
||||
break;
|
||||
case "header":
|
||||
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? itemVal : Header.HeaderSkipper);
|
||||
Header.HeaderSkipper = (Header.HeaderSkipper == null ? itemVal : Header.HeaderSkipper);
|
||||
break;
|
||||
case "type":
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? itemVal : Header.Type);
|
||||
Header.Type = (Header.Type == null ? itemVal : Header.Type);
|
||||
superdat = superdat || itemVal.Contains("SuperDAT");
|
||||
break;
|
||||
case "forcemerging":
|
||||
|
||||
@@ -104,18 +104,21 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <summary>
|
||||
/// Force a merging style when loaded
|
||||
/// </summary>
|
||||
/// TODO: Make nullable
|
||||
[JsonProperty("forcemerging")]
|
||||
public ForceMerging ForceMerging { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Force nodump handling when loaded
|
||||
/// </summary>
|
||||
/// TODO: Make nullable
|
||||
[JsonProperty("forcenodump")]
|
||||
public ForceNodump ForceNodump { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Force output packing when loaded
|
||||
/// </summary>
|
||||
/// TODO: Make nullable
|
||||
[JsonProperty("forcepacking")]
|
||||
public ForcePacking ForcePacking { get; set; }
|
||||
|
||||
|
||||
@@ -109,25 +109,25 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (itemKey)
|
||||
{
|
||||
case "name":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? itemVal : Header.Name);
|
||||
Header.Name = (Header.Name == null ? itemVal : Header.Name);
|
||||
break;
|
||||
case "description":
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? itemVal : Header.Description);
|
||||
Header.Description = (Header.Description == null ? itemVal : Header.Description);
|
||||
break;
|
||||
case "dersion":
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? itemVal : Header.Version);
|
||||
Header.Version = (Header.Version == null ? itemVal : Header.Version);
|
||||
break;
|
||||
case "date":
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? itemVal : Header.Date);
|
||||
Header.Date = (Header.Date == null ? itemVal : Header.Date);
|
||||
break;
|
||||
case "author":
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? itemVal : Header.Author);
|
||||
Header.Author = (Header.Author == null ? itemVal : Header.Author);
|
||||
break;
|
||||
case "homepage":
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? itemVal : Header.Homepage);
|
||||
Header.Homepage = (Header.Homepage == null ? itemVal : Header.Homepage);
|
||||
break;
|
||||
case "comment":
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? itemVal : Header.Comment);
|
||||
Header.Comment = (Header.Comment == null ? itemVal : Header.Comment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,67 +122,67 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
case "name":
|
||||
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");
|
||||
if (keep && superdat)
|
||||
{
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type);
|
||||
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
|
||||
}
|
||||
break;
|
||||
|
||||
case "description":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description);
|
||||
Header.Description = (Header.Description == null ? content : Header.Description);
|
||||
break;
|
||||
|
||||
case "rootdir": // This is exclusive to TruRip XML
|
||||
content = jtr.ReadAsString();
|
||||
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir);
|
||||
Header.RootDir = (Header.RootDir == null ? content : Header.RootDir);
|
||||
break;
|
||||
|
||||
case "category":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category);
|
||||
Header.Category = (Header.Category == null ? content : Header.Category);
|
||||
break;
|
||||
|
||||
case "version":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version);
|
||||
Header.Version = (Header.Version == null ? content : Header.Version);
|
||||
break;
|
||||
|
||||
case "date":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date);
|
||||
Header.Date = (Header.Date == null ? content.Replace(".", "/") : Header.Date);
|
||||
break;
|
||||
|
||||
case "author":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author);
|
||||
Header.Author = (Header.Author == null ? content : Header.Author);
|
||||
break;
|
||||
|
||||
case "email":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? content : Header.Email);
|
||||
Header.Email = (Header.Email == null ? content : Header.Email);
|
||||
break;
|
||||
|
||||
case "homepage":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? content : Header.Homepage);
|
||||
Header.Homepage = (Header.Homepage == null ? content : Header.Homepage);
|
||||
break;
|
||||
|
||||
case "url":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? content : Header.Url);
|
||||
Header.Url = (Header.Url == null ? content : Header.Url);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
content = jtr.ReadAsString();
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment);
|
||||
Header.Comment = (Header.Comment == null ? content : Header.Comment);
|
||||
break;
|
||||
|
||||
case "type": // This is exclusive to TruRip XML
|
||||
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");
|
||||
break;
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
case "header":
|
||||
content = jtr.ReadAsString();
|
||||
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? content : Header.HeaderSkipper);
|
||||
Header.HeaderSkipper = (Header.HeaderSkipper == null ? content : Header.HeaderSkipper);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -64,18 +64,18 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "mame":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? xtr.GetAttribute("build") : Header.Name);
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? Header.Name : Header.Description);
|
||||
// string mame_debug = xtr.GetAttribute("debug"); // (yes|no) "no"
|
||||
// string mame_mameconfig = xtr.GetAttribute("mameconfig"); CDATA
|
||||
Header.Name = (Header.Name == null ? xtr.GetAttribute("build") : Header.Name);
|
||||
Header.Description = (Header.Description == null ? Header.Name : Header.Description);
|
||||
string mame_debug = xtr.GetAttribute("debug"); // (yes|no) "no"
|
||||
string mame_mameconfig = xtr.GetAttribute("mameconfig"); // CDATA
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
// Handle M1 DATs since they're 99% the same as a SL DAT
|
||||
case "m1":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? "M1" : Header.Name);
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? "M1" : Header.Description);
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? xtr.GetAttribute("version") ?? string.Empty : Header.Version);
|
||||
Header.Name = (Header.Name == null ? "M1" : Header.Name);
|
||||
Header.Description = (Header.Description == null ? "M1" : Header.Description);
|
||||
Header.Version = (Header.Version == null ? xtr.GetAttribute("version") ?? string.Empty : Header.Version);
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
|
||||
@@ -153,72 +153,72 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
case "name":
|
||||
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");
|
||||
if (keep && superdat)
|
||||
{
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type);
|
||||
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
|
||||
}
|
||||
break;
|
||||
|
||||
case "description":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description);
|
||||
Header.Description = (Header.Description == null ? content : Header.Description);
|
||||
break;
|
||||
|
||||
case "rootdir": // This is exclusive to TruRip XML
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir);
|
||||
Header.RootDir = (Header.RootDir == null ? content : Header.RootDir);
|
||||
break;
|
||||
|
||||
case "category":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category);
|
||||
Header.Category = (Header.Category == null ? content : Header.Category);
|
||||
break;
|
||||
|
||||
case "version":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version);
|
||||
Header.Version = (Header.Version == null ? content : Header.Version);
|
||||
break;
|
||||
|
||||
case "date":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date);
|
||||
Header.Date = (Header.Date == null ? content.Replace(".", "/") : Header.Date);
|
||||
break;
|
||||
|
||||
case "author":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author);
|
||||
Header.Author = (Header.Author == null ? content : Header.Author);
|
||||
break;
|
||||
|
||||
case "email":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? content : Header.Email);
|
||||
Header.Email = (Header.Email == null ? content : Header.Email);
|
||||
break;
|
||||
|
||||
case "homepage":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? content : Header.Homepage);
|
||||
Header.Homepage = (Header.Homepage == null ? content : Header.Homepage);
|
||||
break;
|
||||
|
||||
case "url":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? content : Header.Url);
|
||||
Header.Url = (Header.Url == null ? content : Header.Url);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment);
|
||||
Header.Comment = (Header.Comment == null ? content : Header.Comment);
|
||||
break;
|
||||
|
||||
case "type": // This is exclusive to TruRip XML
|
||||
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");
|
||||
break;
|
||||
|
||||
case "clrmamepro":
|
||||
if (string.IsNullOrWhiteSpace(Header.HeaderSkipper))
|
||||
if (Header.HeaderSkipper == null)
|
||||
Header.HeaderSkipper = reader.GetAttribute("header");
|
||||
|
||||
if (Header.ForceMerging == ForceMerging.None)
|
||||
|
||||
@@ -124,17 +124,17 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
case "datname":
|
||||
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");
|
||||
if (keep && superdat)
|
||||
{
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type);
|
||||
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
|
||||
}
|
||||
break;
|
||||
|
||||
case "datversion":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version);
|
||||
Header.Version = (Header.Version == null ? content : Header.Version);
|
||||
break;
|
||||
|
||||
case "system":
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "softwaredb":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? "openMSX Software List" : Header.Name);
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? Header.Name : Header.Description);
|
||||
Header.Name = (Header.Name == null ? "openMSX Software List" : Header.Name);
|
||||
Header.Description = (Header.Description == null ? Header.Name : Header.Description);
|
||||
// string timestamp = xtr.GetAttribute("timestamp"); // CDATA
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
@@ -128,37 +128,37 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (kvp?.Key.ToLowerInvariant())
|
||||
{
|
||||
case "author":
|
||||
Header.Author = string.IsNullOrWhiteSpace(Header.Author) ? kvp?.Value : Header.Author;
|
||||
Header.Author = Header.Author == null ? kvp?.Value : Header.Author;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "version":
|
||||
Header.Version = string.IsNullOrWhiteSpace(Header.Version) ? kvp?.Value : Header.Version;
|
||||
Header.Version = Header.Version == null ? kvp?.Value : Header.Version;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "email":
|
||||
Header.Email = string.IsNullOrWhiteSpace(Header.Email) ? kvp?.Value : Header.Email;
|
||||
Header.Email = Header.Email == null ? kvp?.Value : Header.Email;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "homepage":
|
||||
Header.Homepage = string.IsNullOrWhiteSpace(Header.Homepage) ? kvp?.Value : Header.Homepage;
|
||||
Header.Homepage = Header.Homepage == null ? kvp?.Value : Header.Homepage;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "url":
|
||||
Header.Url = string.IsNullOrWhiteSpace(Header.Url) ? kvp?.Value : Header.Url;
|
||||
Header.Url = Header.Url == null ? kvp?.Value : Header.Url;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "date":
|
||||
Header.Date = string.IsNullOrWhiteSpace(Header.Date) ? kvp?.Value : Header.Date;
|
||||
Header.Date = Header.Date == null ? kvp?.Value : Header.Date;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
Header.Comment = string.IsNullOrWhiteSpace(Header.Comment) ? kvp?.Value : Header.Comment;
|
||||
Header.Comment = Header.Comment == null ? kvp?.Value : Header.Comment;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
@@ -265,12 +265,12 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (kvp?.Key.ToLowerInvariant())
|
||||
{
|
||||
case "refname":
|
||||
Header.Name = string.IsNullOrWhiteSpace(Header.Name) ? kvp?.Value : Header.Name;
|
||||
Header.Name = Header.Name == null ? kvp?.Value : Header.Name;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
case "version":
|
||||
Header.Description = string.IsNullOrWhiteSpace(Header.Description) ? kvp?.Value : Header.Description;
|
||||
Header.Description = Header.Description == null ? kvp?.Value : Header.Description;
|
||||
reader.ReadNextLine();
|
||||
break;
|
||||
|
||||
|
||||
@@ -157,50 +157,50 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
case "name":
|
||||
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");
|
||||
if (keep && superdat)
|
||||
{
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? "SuperDAT" : Header.Type);
|
||||
Header.Type = (Header.Type == null ? "SuperDAT" : Header.Type);
|
||||
}
|
||||
break;
|
||||
|
||||
case "description":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? content : Header.Description);
|
||||
Header.Description = (Header.Description== null ? content : Header.Description);
|
||||
break;
|
||||
|
||||
case "rootdir":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? content : Header.RootDir);
|
||||
Header.RootDir = (Header.RootDir== null ? content : Header.RootDir);
|
||||
break;
|
||||
|
||||
case "category":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? content : Header.Category);
|
||||
Header.Category = (Header.Category== null ? content : Header.Category);
|
||||
break;
|
||||
|
||||
case "version":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? content : Header.Version);
|
||||
Header.Version = (Header.Version== null ? content : Header.Version);
|
||||
break;
|
||||
|
||||
case "date":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? content.Replace(".", "/") : Header.Date);
|
||||
Header.Date = (Header.Date== null ? content.Replace(".", "/") : Header.Date);
|
||||
break;
|
||||
|
||||
case "author":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? content : Header.Author);
|
||||
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? reader.GetAttribute("email") : Header.Email);
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? reader.GetAttribute("homepage") : Header.Homepage);
|
||||
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? reader.GetAttribute("url") : Header.Url);
|
||||
Header.Author = (Header.Author== null ? content : Header.Author);
|
||||
Header.Email = (Header.Email == null ? reader.GetAttribute("email") : Header.Email);
|
||||
Header.Homepage = (Header.Homepage == null ? reader.GetAttribute("homepage") : Header.Homepage);
|
||||
Header.Url = (Header.Url == null ? reader.GetAttribute("url") : Header.Url);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
content = reader.ReadElementContentAsString();
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? content : Header.Comment);
|
||||
Header.Comment = (Header.Comment== null ? content : Header.Comment);
|
||||
break;
|
||||
|
||||
case "flags":
|
||||
@@ -493,7 +493,7 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (reader.GetAttribute("name").ToLowerInvariant())
|
||||
{
|
||||
case "type":
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? content : Header.Type);
|
||||
Header.Type = (Header.Type == null ? content : Header.Type);
|
||||
superdat = superdat || content.Contains("SuperDAT");
|
||||
break;
|
||||
|
||||
|
||||
@@ -117,59 +117,59 @@ namespace SabreTools.Library.DatFiles
|
||||
#region DatFile
|
||||
|
||||
case "DatFile.FileName":
|
||||
Header.FileName = (string.IsNullOrWhiteSpace(Header.FileName) ? value : Header.FileName);
|
||||
Header.FileName = (Header.FileName== null ? value : Header.FileName);
|
||||
break;
|
||||
|
||||
case "DatFile.Name":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? value : Header.Name);
|
||||
Header.Name = (Header.Name== null ? value : Header.Name);
|
||||
break;
|
||||
|
||||
case "DatFile.Description":
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? value : Header.Description);
|
||||
Header.Description = (Header.Description== null ? value : Header.Description);
|
||||
break;
|
||||
|
||||
case "DatFile.RootDir":
|
||||
Header.RootDir = (string.IsNullOrWhiteSpace(Header.RootDir) ? value : Header.RootDir);
|
||||
Header.RootDir = (Header.RootDir== null ? value : Header.RootDir);
|
||||
break;
|
||||
|
||||
case "DatFile.Category":
|
||||
Header.Category = (string.IsNullOrWhiteSpace(Header.Category) ? value : Header.Category);
|
||||
Header.Category = (Header.Category== null ? value : Header.Category);
|
||||
break;
|
||||
|
||||
case "DatFile.Version":
|
||||
Header.Version = (string.IsNullOrWhiteSpace(Header.Version) ? value : Header.Version);
|
||||
Header.Version = (Header.Version== null ? value : Header.Version);
|
||||
break;
|
||||
|
||||
case "DatFile.Date":
|
||||
Header.Date = (string.IsNullOrWhiteSpace(Header.Date) ? value : Header.Date);
|
||||
Header.Date = (Header.Date== null ? value : Header.Date);
|
||||
break;
|
||||
|
||||
case "DatFile.Author":
|
||||
Header.Author = (string.IsNullOrWhiteSpace(Header.Author) ? value : Header.Author);
|
||||
Header.Author = (Header.Author== null ? value : Header.Author);
|
||||
break;
|
||||
|
||||
case "DatFile.Email":
|
||||
Header.Email = (string.IsNullOrWhiteSpace(Header.Email) ? value : Header.Email);
|
||||
Header.Email = (Header.Email== null ? value : Header.Email);
|
||||
break;
|
||||
|
||||
case "DatFile.Homepage":
|
||||
Header.Homepage = (string.IsNullOrWhiteSpace(Header.Homepage) ? value : Header.Homepage);
|
||||
Header.Homepage = (Header.Homepage== null ? value : Header.Homepage);
|
||||
break;
|
||||
|
||||
case "DatFile.Url":
|
||||
Header.Url = (string.IsNullOrWhiteSpace(Header.Url) ? value : Header.Url);
|
||||
Header.Url = (Header.Url== null ? value : Header.Url);
|
||||
break;
|
||||
|
||||
case "DatFile.Comment":
|
||||
Header.Comment = (string.IsNullOrWhiteSpace(Header.Comment) ? value : Header.Comment);
|
||||
Header.Comment = (Header.Comment== null ? value : Header.Comment);
|
||||
break;
|
||||
|
||||
case "DatFile.Header":
|
||||
Header.HeaderSkipper = (string.IsNullOrWhiteSpace(Header.HeaderSkipper) ? value : Header.HeaderSkipper);
|
||||
Header.HeaderSkipper = (Header.HeaderSkipper== null ? value : Header.HeaderSkipper);
|
||||
break;
|
||||
|
||||
case "DatFile.Type":
|
||||
Header.Type = (string.IsNullOrWhiteSpace(Header.Type) ? value : Header.Type);
|
||||
Header.Type = (Header.Type== null ? value : Header.Type);
|
||||
break;
|
||||
|
||||
case "DatFile.ForceMerging":
|
||||
@@ -292,15 +292,15 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.Name":
|
||||
name = string.IsNullOrWhiteSpace(value) ? name : value;
|
||||
name = value;
|
||||
break;
|
||||
|
||||
case "DatItem.PartName":
|
||||
partName = string.IsNullOrWhiteSpace(value) ? partName : value;
|
||||
partName = value;
|
||||
break;
|
||||
|
||||
case "DatItem.PartInterface":
|
||||
partInterface = string.IsNullOrWhiteSpace(value) ? partInterface : value;
|
||||
partInterface = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Features":
|
||||
@@ -315,7 +315,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.AreaName":
|
||||
areaName = string.IsNullOrWhiteSpace(value) ? areaName : value;
|
||||
areaName = value;
|
||||
break;
|
||||
|
||||
case "DatItem.AreaSize":
|
||||
@@ -331,7 +331,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.Description":
|
||||
biosDescription = string.IsNullOrWhiteSpace(value) ? biosDescription : value;
|
||||
biosDescription = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Size":
|
||||
@@ -371,15 +371,15 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.Merge":
|
||||
merge = string.IsNullOrWhiteSpace(value) ? merge : value;
|
||||
merge = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Region":
|
||||
region = string.IsNullOrWhiteSpace(value) ? region : value;
|
||||
region = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Index":
|
||||
index = string.IsNullOrWhiteSpace(value) ? index : value;
|
||||
index = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Writable":
|
||||
@@ -395,7 +395,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.Language":
|
||||
language = string.IsNullOrWhiteSpace(value) ? language : value;
|
||||
language = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Date":
|
||||
@@ -403,11 +403,11 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "DatItem.Bios":
|
||||
bios = string.IsNullOrWhiteSpace(value) ? bios : value;
|
||||
bios = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Offset":
|
||||
offset = string.IsNullOrWhiteSpace(value) ? offset : value;
|
||||
offset = value;
|
||||
break;
|
||||
|
||||
case "DatItem.Inverted":
|
||||
|
||||
@@ -62,8 +62,8 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "softwarelist":
|
||||
Header.Name = (string.IsNullOrWhiteSpace(Header.Name) ? xtr.GetAttribute("name") ?? string.Empty : Header.Name);
|
||||
Header.Description = (string.IsNullOrWhiteSpace(Header.Description) ? xtr.GetAttribute("description") ?? string.Empty : Header.Description);
|
||||
Header.Name = (Header.Name == null ? xtr.GetAttribute("name") ?? string.Empty : Header.Name);
|
||||
Header.Description = (Header.Description == null ? xtr.GetAttribute("description") ?? string.Empty : Header.Description);
|
||||
if (Header.ForceMerging == ForceMerging.None)
|
||||
Header.ForceMerging = xtr.GetAttribute("forcemerging").AsForceMerging();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user