mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Clean up based on .NET Core 3.1 reccomendations
This commit is contained in:
@@ -70,88 +70,37 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatFile Create(DatFormat? datFormat = null, DatFile baseDat = null, bool quotes = true)
|
||||
{
|
||||
switch (datFormat)
|
||||
return datFormat switch
|
||||
{
|
||||
case DatFormat.AttractMode:
|
||||
return new AttractMode(baseDat);
|
||||
|
||||
case DatFormat.ClrMamePro:
|
||||
return new ClrMamePro(baseDat, quotes);
|
||||
|
||||
case DatFormat.CSV:
|
||||
return new Formats.SeparatedValue(baseDat, ',');
|
||||
|
||||
case DatFormat.DOSCenter:
|
||||
return new DosCenter(baseDat);
|
||||
|
||||
case DatFormat.EverdriveSMDB:
|
||||
return new EverdriveSMDB(baseDat);
|
||||
|
||||
case DatFormat.Listrom:
|
||||
return new Listrom(baseDat);
|
||||
|
||||
case DatFormat.Listxml:
|
||||
return new Listxml(baseDat);
|
||||
|
||||
case DatFormat.Logiqx:
|
||||
return new Logiqx(baseDat, false);
|
||||
|
||||
case DatFormat.LogiqxDeprecated:
|
||||
return new Logiqx(baseDat, true);
|
||||
|
||||
case DatFormat.MissFile:
|
||||
return new Missfile(baseDat);
|
||||
|
||||
case DatFormat.OfflineList:
|
||||
return new OfflineList(baseDat);
|
||||
|
||||
case DatFormat.OpenMSX:
|
||||
return new OpenMSX(baseDat);
|
||||
|
||||
case DatFormat.RedumpMD5:
|
||||
return new Hashfile(baseDat, Hash.MD5);
|
||||
|
||||
case DatFormat.RedumpSFV:
|
||||
return new Hashfile(baseDat, Hash.CRC);
|
||||
|
||||
case DatFormat.RedumpSHA1:
|
||||
return new Hashfile(baseDat, Hash.SHA1);
|
||||
|
||||
case DatFormat.RedumpSHA256:
|
||||
return new Hashfile(baseDat, Hash.SHA256);
|
||||
|
||||
case DatFormat.RedumpSHA384:
|
||||
return new Hashfile(baseDat, Hash.SHA384);
|
||||
|
||||
case DatFormat.RedumpSHA512:
|
||||
return new Hashfile(baseDat, Hash.SHA512);
|
||||
|
||||
case DatFormat.RedumpSpamSum:
|
||||
return new Hashfile(baseDat, Hash.SpamSum);
|
||||
|
||||
case DatFormat.RomCenter:
|
||||
return new RomCenter(baseDat);
|
||||
|
||||
case DatFormat.SabreJSON:
|
||||
return new SabreJSON(baseDat);
|
||||
|
||||
case DatFormat.SabreXML:
|
||||
return new SabreXML(baseDat);
|
||||
|
||||
case DatFormat.SoftwareList:
|
||||
return new Formats.SoftwareList(baseDat);
|
||||
|
||||
case DatFormat.SSV:
|
||||
return new Formats.SeparatedValue(baseDat, ';');
|
||||
|
||||
case DatFormat.TSV:
|
||||
return new Formats.SeparatedValue(baseDat, '\t');
|
||||
|
||||
DatFormat.AttractMode => new AttractMode(baseDat),
|
||||
DatFormat.ClrMamePro => new ClrMamePro(baseDat, quotes),
|
||||
DatFormat.CSV => new SeparatedValue(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.RedumpMD5 => new Hashfile(baseDat, Hash.MD5),
|
||||
DatFormat.RedumpSFV => new Hashfile(baseDat, Hash.CRC),
|
||||
DatFormat.RedumpSHA1 => new Hashfile(baseDat, Hash.SHA1),
|
||||
DatFormat.RedumpSHA256 => new Hashfile(baseDat, Hash.SHA256),
|
||||
DatFormat.RedumpSHA384 => new Hashfile(baseDat, Hash.SHA384),
|
||||
DatFormat.RedumpSHA512 => new Hashfile(baseDat, Hash.SHA512),
|
||||
DatFormat.RedumpSpamSum => new Hashfile(baseDat, Hash.SpamSum),
|
||||
DatFormat.RomCenter => new RomCenter(baseDat),
|
||||
DatFormat.SabreJSON => new SabreJSON(baseDat),
|
||||
DatFormat.SabreXML => new SabreXML(baseDat),
|
||||
DatFormat.SoftwareList => new Formats.SoftwareList(baseDat),
|
||||
DatFormat.SSV => new SeparatedValue(baseDat, ';'),
|
||||
DatFormat.TSV => new SeparatedValue(baseDat, '\t'),
|
||||
|
||||
// We use new-style Logiqx as a backup for generic DatFile
|
||||
case null:
|
||||
default:
|
||||
return new Logiqx(baseDat, false);
|
||||
}
|
||||
_ => new Logiqx(baseDat, false),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -213,7 +162,7 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>The key for the item</returns>
|
||||
protected string ParseAddHelper(DatItem item)
|
||||
{
|
||||
string key = string.Empty;
|
||||
string key;
|
||||
|
||||
// If we have a Disk, Media, or Rom, clean the hash data
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
@@ -344,7 +293,7 @@ namespace SabreTools.DatFiles
|
||||
protected string CreatePrefixPostfix(DatItem item, bool prefix)
|
||||
{
|
||||
// Initialize strings
|
||||
string fix = string.Empty,
|
||||
string fix,
|
||||
game = item.Machine.Name,
|
||||
name = item.GetName() ?? item.ItemType.ToString(),
|
||||
crc = string.Empty,
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
Rom rom = new Rom
|
||||
{
|
||||
Name = svr.Line[1].Substring(fullname[0].Length + 1),
|
||||
Name = svr.Line[1][(fullname[0].Length + 1)..],
|
||||
Size = null, // No size provided, but we don't want the size being 0
|
||||
CRC = svr.Line[4],
|
||||
MD5 = svr.Line[3],
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
// Get the hash field and set final fields
|
||||
string hash = string.Empty;
|
||||
string hash;
|
||||
switch (_hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
logger.Warning($"Possibly malformed line: '{line}'");
|
||||
|
||||
string romname = split[0];
|
||||
line = line.Substring(romname.Length);
|
||||
line = line[romname.Length..];
|
||||
|
||||
// Next we separate the ROM into pieces
|
||||
split = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
@@ -398,8 +398,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
string key = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
bool containsItems = false;
|
||||
|
||||
// Create a new machine
|
||||
@@ -497,7 +495,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
archive.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the archive
|
||||
key = ParseAddHelper(archive);
|
||||
ParseAddHelper(archive);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -521,7 +519,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
biosSet.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the biosSet
|
||||
key = ParseAddHelper(biosSet);
|
||||
ParseAddHelper(biosSet);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -547,7 +545,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
disk.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the disk
|
||||
key = ParseAddHelper(disk);
|
||||
ParseAddHelper(disk);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -573,7 +571,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
media.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the media
|
||||
key = ParseAddHelper(media);
|
||||
ParseAddHelper(media);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -593,7 +591,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
release.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the release
|
||||
key = ParseAddHelper(release);
|
||||
ParseAddHelper(release);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -627,7 +625,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
rom.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(rom);
|
||||
ParseAddHelper(rom);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -649,7 +647,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
sample.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the sample
|
||||
key = ParseAddHelper(sample);
|
||||
ParseAddHelper(sample);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
@@ -536,7 +536,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return base.CreateProperties(type, memberSerialization)
|
||||
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList();
|
||||
|
||||
IEnumerable<Type> BaseTypesAndSelf(Type t)
|
||||
static IEnumerable<Type> BaseTypesAndSelf(Type t)
|
||||
{
|
||||
while (t != null)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Internal dictionary for the class
|
||||
/// </summary>
|
||||
private ConcurrentDictionary<string, List<DatItem>> items;
|
||||
private readonly ConcurrentDictionary<string, List<DatItem>> items;
|
||||
|
||||
/// <summary>
|
||||
/// Lock for statistics calculation
|
||||
@@ -44,12 +44,7 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Logging object
|
||||
/// </summary>
|
||||
private Logger logger;
|
||||
|
||||
/// <summary>
|
||||
/// Static logger for static methods
|
||||
/// </summary>
|
||||
private static Logger staticLogger = new Logger();
|
||||
private readonly Logger logger;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user