diff --git a/SabreTools.DatFiles.Test/DatFileTests.cs b/SabreTools.DatFiles.Test/DatFileTests.cs index 2b4b2014..0842552f 100644 --- a/SabreTools.DatFiles.Test/DatFileTests.cs +++ b/SabreTools.DatFiles.Test/DatFileTests.cs @@ -220,9 +220,9 @@ namespace SabreTools.DatFiles.Test #endregion - #region ProcessItemNameDB + #region FormatPrefixPostfix - // TODO: Write ProcessItemNameDB tests + // TODO: Write FormatPrefixPostfix tests #endregion diff --git a/SabreTools.DatFiles/DatFile.cs b/SabreTools.DatFiles/DatFile.cs index a4da00a2..40aa9493 100644 --- a/SabreTools.DatFiles/DatFile.cs +++ b/SabreTools.DatFiles/DatFile.cs @@ -202,15 +202,19 @@ namespace SabreTools.DatFiles bool quotes = forceRemoveQuotes ? false : Header.GetBoolFieldValue(DatHeader.QuotesKey) ?? false; bool useRomName = forceRomName ? true : Header.GetBoolFieldValue(DatHeader.UseRomNameKey) ?? false; + // Create the full Prefix + string pre = Header.GetStringFieldValue(DatHeader.PrefixKey) + (quotes ? "\"" : string.Empty); + pre = FormatPrefixPostfix(item, machine, pre); + + // Create the full Postfix + string post = (quotes ? "\"" : string.Empty) + Header.GetStringFieldValue(DatHeader.PostfixKey); + post = FormatPrefixPostfix(item, machine, post); + // Get the name to update string? name = (useRomName == true ? item.GetName() : machine?.GetStringFieldValue(Models.Metadata.Machine.NameKey)) ?? string.Empty; - // Create the proper Prefix and Postfix - string pre = CreatePrefix(item, machine, quotes); - string post = CreatePostfix(item, machine, quotes); - // If we're in Depot mode, take care of that instead var outputDepot = Header.GetFieldValue(DatHeader.OutputDepotKey); if (outputDepot?.IsActive == true) @@ -279,40 +283,6 @@ namespace SabreTools.DatFiles machine.SetFieldValue(Models.Metadata.Machine.NameKey, name); } - /// - /// Create a prefix from inputs - /// - /// DatItem to create a prefix/postfix for - /// Machine to get information from - /// True to quote names, false otherwise - /// Sanitized string representing the postfix or prefix - protected string CreatePrefix(DatItem item, Machine? machine, bool quotes) - { - // Create the prefix pattern - string? prefixString = Header.GetStringFieldValue(DatHeader.PrefixKey); - string fix = prefixString + (quotes ? "\"" : string.Empty); - - // Format and return the pattern - return FormatPrefixPostfix(item, machine, fix); - } - - /// - /// Create a postfix from inputs - /// - /// DatItem to create a prefix/postfix for - /// Machine to get information from - /// True to quote names, false otherwise - /// Sanitized string representing the postfix or prefix - protected string CreatePostfix(DatItem item, Machine? machine, bool quotes) - { - // Create the prefix pattern - string? postfixString = Header.GetStringFieldValue(DatHeader.PostfixKey); - string fix = (quotes ? "\"" : string.Empty) + postfixString; - - // Format and return the pattern - return FormatPrefixPostfix(item, machine, fix); - } - /// /// Format a prefix or postfix string ///