Semi-fix DatHeader constructor

This commit is contained in:
Matt Nadareski
2025-01-30 13:01:07 -05:00
parent 8264695473
commit 92c2be7eb1

View File

@@ -83,24 +83,25 @@ namespace SabreTools.DatFiles
public DatHeader(Models.Metadata.Header header) public DatHeader(Models.Metadata.Header header)
{ {
// Create a new internal model
_internal = new Models.Metadata.Header();
// Get all fields to automatically copy without processing // Get all fields to automatically copy without processing
var nonItemFields = TypeHelper.GetConstants(typeof(Models.Metadata.Header)); var nonItemFields = TypeHelper.GetConstants(typeof(Models.Metadata.Header));
if (nonItemFields == null) if (nonItemFields != null)
return; {
// Populate the internal machine from non-filter fields // Populate the internal machine from non-filter fields
_internal = new Models.Metadata.Header();
foreach (string fieldName in nonItemFields) foreach (string fieldName in nonItemFields)
{ {
if (header.ContainsKey(fieldName)) if (header.ContainsKey(fieldName))
_internal[fieldName] = header[fieldName]; _internal[fieldName] = header[fieldName];
} }
}
// Get all fields specific to the DatFiles implementation // Get all fields specific to the DatFiles implementation
var nonStandardFields = TypeHelper.GetConstants(typeof(DatHeader)); var nonStandardFields = TypeHelper.GetConstants(typeof(DatHeader));
if (nonStandardFields == null) if (nonStandardFields != null)
return; {
// Populate the internal machine from filter fields // Populate the internal machine from filter fields
foreach (string fieldName in nonStandardFields) foreach (string fieldName in nonStandardFields)
{ {
@@ -108,6 +109,7 @@ namespace SabreTools.DatFiles
_internal[fieldName] = header[fieldName]; _internal[fieldName] = header[fieldName];
} }
} }
}
#endregion #endregion