mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move DatFile creation helper to Parser
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatFiles.Formats;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
using SabreTools.IO.Logging;
|
||||
@@ -21,68 +20,6 @@ namespace SabreTools.DatFiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creation
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of DatFile to be used based on a format and a base DAT
|
||||
/// </summary>
|
||||
/// <param name="datFormat">Format of the DAT to be created, default is <see cref="DatFormat.Logiqx"/> </param>
|
||||
/// <param name="baseDat">DatFile containing the information to use in specific operations, default is null</param>
|
||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatFile CreateDatFile(DatFormat datFormat = DatFormat.Logiqx, DatFile? baseDat = null)
|
||||
{
|
||||
return datFormat switch
|
||||
{
|
||||
DatFormat.ArchiveDotOrg => new ArchiveDotOrg(baseDat),
|
||||
DatFormat.AttractMode => new AttractMode(baseDat),
|
||||
DatFormat.ClrMamePro => new ClrMamePro(baseDat),
|
||||
DatFormat.CSV => new CommaSeparatedValue(baseDat),
|
||||
DatFormat.DOSCenter => new DosCenter(baseDat),
|
||||
DatFormat.EverdriveSMDB => new EverdriveSMDB(baseDat),
|
||||
DatFormat.Listrom => new Listrom(baseDat),
|
||||
DatFormat.Listxml => new Listxml(baseDat),
|
||||
DatFormat.Logiqx => new Logiqx(baseDat, false),
|
||||
DatFormat.LogiqxDeprecated => new Logiqx(baseDat, true),
|
||||
DatFormat.MissFile => new Missfile(baseDat),
|
||||
DatFormat.OfflineList => new OfflineList(baseDat),
|
||||
DatFormat.OpenMSX => new OpenMSX(baseDat),
|
||||
DatFormat.RedumpMD2 => new Md2File(baseDat),
|
||||
DatFormat.RedumpMD4 => new Md4File(baseDat),
|
||||
DatFormat.RedumpMD5 => new Md5File(baseDat),
|
||||
DatFormat.RedumpSFV => new SfvFile(baseDat),
|
||||
DatFormat.RedumpSHA1 => new Sha1File(baseDat),
|
||||
DatFormat.RedumpSHA256 => new Sha256File(baseDat),
|
||||
DatFormat.RedumpSHA384 => new Sha384File(baseDat),
|
||||
DatFormat.RedumpSHA512 => new Sha512File(baseDat),
|
||||
DatFormat.RedumpSpamSum => new SpamSumFile(baseDat),
|
||||
DatFormat.RomCenter => new RomCenter(baseDat),
|
||||
DatFormat.SabreJSON => new SabreJSON(baseDat),
|
||||
DatFormat.SabreXML => new SabreXML(baseDat),
|
||||
DatFormat.SoftwareList => new Formats.SoftwareList(baseDat),
|
||||
DatFormat.SSV => new SemicolonSeparatedValue(baseDat),
|
||||
DatFormat.TSV => new TabSeparatedValue(baseDat),
|
||||
|
||||
// We use new-style Logiqx as a backup for generic DatFile
|
||||
_ => new Logiqx(baseDat, false),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new DatFile from an existing DatHeader
|
||||
/// </summary>
|
||||
/// <param name="datHeader">DatHeader to get the values from</param>
|
||||
/// <param name="datModifiers">DatModifiers to get the values from</param>
|
||||
public static DatFile CreateDatFile(DatHeader datHeader, DatModifiers datModifiers)
|
||||
{
|
||||
DatFormat format = datHeader.GetFieldValue<DatFormat>(DatHeader.DatFormatKey);
|
||||
DatFile datFile = CreateDatFile(format);
|
||||
datFile.SetHeader(datHeader);
|
||||
datFile.SetModifiers(datModifiers);
|
||||
return datFile;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user