Fix mismatched DB implementations

This commit is contained in:
Matt Nadareski
2025-01-09 10:05:16 -05:00
parent 68c235f716
commit b27d73da13
2 changed files with 45 additions and 2 deletions

View File

@@ -503,7 +503,7 @@ namespace SabreTools.DatFiles.Formats
// Write out the item if we're not ignoring
if (!ShouldIgnore(datItem.Value, ignoreblanks))
WriteDatItem(jtw, datItem.Value);
WriteDatItemDB(jtw, datItem);
// Set the new data to compare against
lastgame = machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
@@ -609,6 +609,30 @@ namespace SabreTools.DatFiles.Formats
jtw.Flush();
}
/// <summary>
/// Write out DatItem using the supplied JsonTextWriter
/// </summary>
/// <param name="jtw">JsonTextWriter to output to</param>
/// <param name="datItem">DatItem object to be output</param>
private void WriteDatItemDB(JsonTextWriter jtw, KeyValuePair<long, DatItem> datItem)
{
// Pre-process the item name
ProcessItemNameDB(datItem, true);
// Build the state
jtw.WriteStartObject();
// Write the DatItem
jtw.WritePropertyName("datitem");
JsonSerializer js = new() { ContractResolver = new BaseFirstContractResolver(), Formatting = Formatting.Indented };
js.Serialize(jtw, datItem);
// End item
jtw.WriteEndObject();
jtw.Flush();
}
/// <summary>
/// Write out DAT footer using the supplied JsonTextWriter
/// </summary>

View File

@@ -332,7 +332,7 @@ namespace SabreTools.DatFiles.Formats
// Write out the item if we're not ignoring
if (!ShouldIgnore(datItem.Value, ignoreblanks))
WriteDatItem(xtw, datItem.Value);
WriteDatItemDB(xtw, datItem);
// Set the new data to compare against
lastgame = machine.Value!.GetStringFieldValue(Models.Metadata.Machine.NameKey);
@@ -433,6 +433,25 @@ namespace SabreTools.DatFiles.Formats
xtw.Flush();
}
/// <summary>
/// Write out DatItem using the supplied StreamWriter
/// </summary>
/// <param name="xtw">XmlTextWriter to output to</param>
/// <param name="datItem">DatItem object to be output</param>
private void WriteDatItemDB(XmlTextWriter xtw, KeyValuePair<long, DatItem> datItem)
{
// Pre-process the item name
ProcessItemNameDB(datItem, true);
// Write the DatItem
XmlSerializer xs = new(typeof(DatItem));
XmlSerializerNamespaces ns = new();
ns.Add("", "");
xs.Serialize(xtw, datItem, ns);
xtw.Flush();
}
/// <summary>
/// Write out DAT footer using the supplied StreamWriter
/// </summary>