mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add nullable context to SabreTools.DatFiles
This commit is contained in:
@@ -172,7 +172,7 @@ namespace SabreTools.Core.Tools
|
||||
/// </summary>
|
||||
/// <param name="path">Path to check</param>
|
||||
/// <returns>True if the extension is valid, false otherwise</returns>
|
||||
public static bool HasValidDatExtension(string path)
|
||||
public static bool HasValidDatExtension(string? path)
|
||||
{
|
||||
// If the path is null or empty, then we return false
|
||||
if (string.IsNullOrEmpty(path))
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.DatFiles
|
||||
/// Create a new DatFile from an existing one
|
||||
/// </summary>
|
||||
/// <param name="datFile">DatFile to get the values from</param>
|
||||
public DatFile(DatFile datFile)
|
||||
public DatFile(DatFile? datFile)
|
||||
{
|
||||
logger = new Logger(this);
|
||||
if (datFile != null)
|
||||
@@ -68,7 +68,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="baseDat">DatFile containing the information to use in specific operations</param>
|
||||
/// <param name="quotes">For relevant types, assume the usage of quotes</param>
|
||||
/// <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)
|
||||
public static DatFile Create(DatFormat? datFormat = null, DatFile? baseDat = null, bool quotes = true)
|
||||
{
|
||||
return datFormat switch
|
||||
{
|
||||
@@ -98,7 +98,7 @@ namespace SabreTools.DatFiles
|
||||
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
|
||||
_ => new Logiqx(baseDat, false),
|
||||
};
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Parsing
|
||||
|
||||
/// <summary>
|
||||
@@ -168,10 +168,8 @@ namespace SabreTools.DatFiles
|
||||
string key;
|
||||
|
||||
// If we have a Disk, Media, or Rom, clean the hash data
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
if (item.ItemType == ItemType.Disk && item is Disk disk)
|
||||
{
|
||||
Disk disk = item as Disk;
|
||||
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (disk.ItemStatus != ItemStatus.Nodump
|
||||
&& string.IsNullOrWhiteSpace(disk.MD5)
|
||||
@@ -183,10 +181,21 @@ namespace SabreTools.DatFiles
|
||||
|
||||
item = disk;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
if (item.ItemType == ItemType.Media && item is Media media)
|
||||
{
|
||||
Rom rom = item as Rom;
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (string.IsNullOrWhiteSpace(media.MD5)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(media.SpamSum))
|
||||
{
|
||||
logger.Verbose($"Incomplete entry for '{media.Name}' will be output as nodump");
|
||||
}
|
||||
|
||||
item = media;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom && item is Rom rom)
|
||||
{
|
||||
// If we have the case where there is SHA-1 and nothing else, we don't fill in any other part of the data
|
||||
if (rom.Size == null && !rom.HasHashes())
|
||||
{
|
||||
@@ -250,10 +259,10 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Date as a string, if possible</returns>
|
||||
protected static string CleanDate(string input)
|
||||
protected static string? CleanDate(string? input)
|
||||
{
|
||||
// Null in, null out
|
||||
if (input == null)
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return null;
|
||||
|
||||
string date = string.Empty;
|
||||
@@ -267,7 +276,7 @@ namespace SabreTools.DatFiles
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clean a hash string from a Listrom DAT
|
||||
/// </summary>
|
||||
@@ -285,7 +294,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <summary>
|
||||
@@ -327,28 +336,28 @@ namespace SabreTools.DatFiles
|
||||
fix = (Header.Quotes ? "\"" : string.Empty) + Header.Postfix;
|
||||
|
||||
// Ensure we have the proper values for replacement
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
if (item.ItemType == ItemType.Disk && item is Disk disk)
|
||||
{
|
||||
md5 = (item as Disk).MD5 ?? string.Empty;
|
||||
sha1 = (item as Disk).SHA1 ?? string.Empty;
|
||||
md5 = disk.MD5 ?? string.Empty;
|
||||
sha1 = disk.SHA1 ?? string.Empty;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
else if (item.ItemType == ItemType.Media && item is Media media)
|
||||
{
|
||||
md5 = (item as Media).MD5 ?? string.Empty;
|
||||
sha1 = (item as Media).SHA1 ?? string.Empty;
|
||||
sha256 = (item as Media).SHA256 ?? string.Empty;
|
||||
spamsum = (item as Media).SpamSum ?? string.Empty;
|
||||
md5 = media.MD5 ?? string.Empty;
|
||||
sha1 = media.SHA1 ?? string.Empty;
|
||||
sha256 = media.SHA256 ?? string.Empty;
|
||||
spamsum = media.SpamSum ?? string.Empty;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
else if (item.ItemType == ItemType.Rom && item is Rom rom)
|
||||
{
|
||||
crc = (item as Rom).CRC ?? string.Empty;
|
||||
md5 = (item as Rom).MD5 ?? string.Empty;
|
||||
sha1 = (item as Rom).SHA1 ?? string.Empty;
|
||||
sha256 = (item as Rom).SHA256 ?? string.Empty;
|
||||
sha384 = (item as Rom).SHA384 ?? string.Empty;
|
||||
sha512 = (item as Rom).SHA512 ?? string.Empty;
|
||||
size = (item as Rom).Size?.ToString() ?? string.Empty;
|
||||
spamsum = (item as Rom).SpamSum ?? string.Empty;
|
||||
crc = rom.CRC ?? string.Empty;
|
||||
md5 = rom.MD5 ?? string.Empty;
|
||||
sha1 = rom.SHA1 ?? string.Empty;
|
||||
sha256 = rom.SHA256 ?? string.Empty;
|
||||
sha384 = rom.SHA384 ?? string.Empty;
|
||||
sha512 = rom.SHA512 ?? string.Empty;
|
||||
size = rom.Size?.ToString() ?? string.Empty;
|
||||
spamsum = rom.SpamSum ?? string.Empty;
|
||||
}
|
||||
|
||||
// Now do bulk replacement where possible
|
||||
@@ -397,10 +406,8 @@ namespace SabreTools.DatFiles
|
||||
// If we're in Depot mode, take care of that instead
|
||||
if (Header.OutputDepot?.IsActive == true)
|
||||
{
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
if (item.ItemType == ItemType.Disk && item is Disk disk)
|
||||
{
|
||||
Disk disk = item as Disk;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
@@ -408,10 +415,8 @@ namespace SabreTools.DatFiles
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
else if (item.ItemType == ItemType.Media && item is Media media)
|
||||
{
|
||||
Media media = item as Media;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(media.SHA1))
|
||||
{
|
||||
@@ -419,10 +424,8 @@ namespace SabreTools.DatFiles
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
else if (item.ItemType == ItemType.Rom && item is Rom rom)
|
||||
{
|
||||
Rom rom = item as Rom;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
{
|
||||
@@ -439,9 +442,12 @@ namespace SabreTools.DatFiles
|
||||
if (Header.RemoveExtension)
|
||||
Header.ReplaceExtension = string.Empty;
|
||||
|
||||
string dir = Path.GetDirectoryName(name);
|
||||
dir = dir.TrimStart(Path.DirectorySeparatorChar);
|
||||
name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + Header.ReplaceExtension);
|
||||
string? dir = Path.GetDirectoryName(name);
|
||||
if (dir != null)
|
||||
{
|
||||
dir = dir.TrimStart(Path.DirectorySeparatorChar);
|
||||
name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + Header.ReplaceExtension);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Header.AddExtension))
|
||||
@@ -477,7 +483,8 @@ namespace SabreTools.DatFiles
|
||||
return datItem;
|
||||
|
||||
// Cast for easier parsing
|
||||
Rom rom = datItem as Rom;
|
||||
if (datItem is not Rom rom)
|
||||
return datItem;
|
||||
|
||||
// If the Rom has "null" characteristics, ensure all fields
|
||||
if (rom.Size == null && rom.CRC == "null")
|
||||
@@ -504,14 +511,14 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>List of supported types for writing</returns>
|
||||
protected virtual ItemType[] GetSupportedTypes()
|
||||
{
|
||||
return Enum.GetValues(typeof(ItemType)) as ItemType[];
|
||||
return Enum.GetValues(typeof(ItemType)) as ItemType[] ?? Array.Empty<ItemType>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return list of required fields missing from a DatItem
|
||||
/// </summary>
|
||||
/// <returns>List of missing required fields, null or empty if none were found</returns>
|
||||
protected virtual List<DatItemField> GetMissingRequiredFields(DatItem datItem) => null;
|
||||
protected virtual List<DatItemField>? GetMissingRequiredFields(DatItem datItem) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Get if a machine contains any writable items
|
||||
@@ -540,7 +547,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="datItem">DatItem to check</param>
|
||||
/// <param name="ignoreBlanks">True if blank roms should be skipped on output, false otherwise</param>
|
||||
/// <returns>True if the item should be skipped on write, false otherwise</returns>
|
||||
protected bool ShouldIgnore(DatItem datItem, bool ignoreBlanks)
|
||||
protected bool ShouldIgnore(DatItem? datItem, bool ignoreBlanks)
|
||||
{
|
||||
// If this is invoked with a null DatItem, we ignore
|
||||
if (datItem == null)
|
||||
@@ -566,10 +573,8 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// If we're ignoring blanks and we have a Rom
|
||||
if (ignoreBlanks && datItem.ItemType == ItemType.Rom)
|
||||
if (ignoreBlanks && datItem.ItemType == ItemType.Rom && datItem is Rom rom)
|
||||
{
|
||||
Rom rom = datItem as Rom;
|
||||
|
||||
// If we have a 0-size or blank rom, then we ignore
|
||||
if (rom.Size == 0 || rom.Size == null)
|
||||
{
|
||||
@@ -588,7 +593,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// If we have an item with missing required fields
|
||||
List<DatItemField> missingFields = GetMissingRequiredFields(datItem);
|
||||
List<DatItemField>? missingFields = GetMissingRequiredFields(datItem);
|
||||
if (missingFields != null && missingFields.Count != 0)
|
||||
{
|
||||
string itemString = JsonConvert.SerializeObject(datItem, Formatting.None);
|
||||
|
||||
@@ -25,98 +25,98 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("filename", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("filename")]
|
||||
public string FileName { get; set; }
|
||||
public string? FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal name of the DAT
|
||||
/// </summary>
|
||||
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("name")]
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DAT description
|
||||
/// </summary>
|
||||
[JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("description")]
|
||||
public string Description { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Root directory for the files; currently TruRip/EmuARC-exclusive
|
||||
/// </summary>
|
||||
[JsonProperty("rootdir", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("rootdir")]
|
||||
public string RootDir { get; set; }
|
||||
public string? RootDir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// General category of items found in the DAT
|
||||
/// </summary>
|
||||
[JsonProperty("category", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("category")]
|
||||
public string Category { get; set; }
|
||||
public string? Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Version of the DAT
|
||||
/// </summary>
|
||||
[JsonProperty("version", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("version")]
|
||||
public string Version { get; set; }
|
||||
public string? Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creation or modification date
|
||||
/// </summary>
|
||||
[JsonProperty("date", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("date")]
|
||||
public string Date { get; set; }
|
||||
public string? Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of authors who contributed to the DAT
|
||||
/// </summary>
|
||||
[JsonProperty("author", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("author")]
|
||||
public string Author { get; set; }
|
||||
public string? Author { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Email address for DAT author(s)
|
||||
/// </summary>
|
||||
[JsonProperty("email", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("email")]
|
||||
public string Email { get; set; }
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Author or distribution homepage name
|
||||
/// </summary>
|
||||
[JsonProperty("homepage", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("homepage")]
|
||||
public string Homepage { get; set; }
|
||||
public string? Homepage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Author or distribution URL
|
||||
/// </summary>
|
||||
[JsonProperty("url", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("url")]
|
||||
public string Url { get; set; }
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any comment that does not already fit an existing field
|
||||
/// </summary>
|
||||
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("comment")]
|
||||
public string Comment { get; set; }
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Header skipper to be used when loading the DAT
|
||||
/// </summary>
|
||||
[JsonProperty("header", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("header")]
|
||||
public string HeaderSkipper { get; set; }
|
||||
public string? HeaderSkipper { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Classification of the DAT. Generally only used for SuperDAT
|
||||
/// </summary>
|
||||
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("type")]
|
||||
public string Type { get; set; }
|
||||
public string? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Force a merging style when loaded
|
||||
@@ -174,7 +174,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("mameconfig", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("mameconfig")]
|
||||
public string MameConfig { get; set; }
|
||||
public string? MameConfig { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -185,21 +185,21 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("nointroid", DefaultValueHandling = DefaultValueHandling.Include)]
|
||||
[XmlElement("nointroid")]
|
||||
public string NoIntroID { get; set; }
|
||||
public string? NoIntroID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Build version
|
||||
/// </summary>
|
||||
[JsonProperty("build", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("build")]
|
||||
public string Build { get; set; }
|
||||
public string? Build { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Logiqx/RomCenter plugin, OfflineList System
|
||||
/// </summary>
|
||||
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("system")]
|
||||
public string System { get; set; }
|
||||
public string? System { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// RomCenter rom mode
|
||||
@@ -283,21 +283,21 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("screenshotswidth", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("screenshotswidth")]
|
||||
public string ScreenshotsWidth { get; set; }
|
||||
public string? ScreenshotsWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Screenshots height
|
||||
/// </summary>
|
||||
[JsonProperty("screenshotsheight", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("screenshotsheight")]
|
||||
public string ScreenshotsHeight { get; set; }
|
||||
public string? ScreenshotsHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OfflineList info list
|
||||
/// </summary>
|
||||
[JsonProperty("infos", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("infos")]
|
||||
public List<OfflineListInfo> Infos { get; set; }
|
||||
public List<OfflineListInfo>? Infos { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool InfosSpecified { get { return Infos != null && Infos.Count > 0; } }
|
||||
@@ -307,7 +307,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("canopen", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("canopen")]
|
||||
public List<string> CanOpen { get; set; }
|
||||
public List<string>? CanOpen { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool CanOpenSpecified { get { return CanOpen != null && CanOpen.Count > 0; } }
|
||||
@@ -325,7 +325,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("romtitle", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("romtitle")]
|
||||
public string RomTitle { get; set; }
|
||||
public string? RomTitle { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
[JsonProperty("rcversion", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("rcversion")]
|
||||
public string RomCenterVersion { get; set; }
|
||||
public string? RomCenterVersion { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -346,25 +346,25 @@ namespace SabreTools.DatFiles
|
||||
/// Text to prepend to all outputted lines
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public string Prefix { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Text to append to all outputted lines
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public string Postfix { get; set; }
|
||||
public string? Postfix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Add a new extension to all items
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public string AddExtension { get; set; }
|
||||
public string? AddExtension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Replace all item extensions
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public string ReplaceExtension { get; set; }
|
||||
public string? ReplaceExtension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remove all item extensions
|
||||
@@ -392,13 +392,13 @@ namespace SabreTools.DatFiles
|
||||
/// Input depot information
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public DepotInformation InputDepot { get; set; }
|
||||
public DepotInformation? InputDepot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Output depot information
|
||||
/// </summary>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public DepotInformation OutputDepot { get; set; }
|
||||
public DepotInformation? OutputDepot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -652,8 +652,11 @@ namespace SabreTools.DatFiles
|
||||
/// Overwrite local values from another DatHeader if not default
|
||||
/// </summary>
|
||||
/// <param name="datHeader">DatHeader to get the values from</param>
|
||||
public void ConditionalCopy(DatHeader datHeader)
|
||||
public void ConditionalCopy(DatHeader? datHeader)
|
||||
{
|
||||
if (datHeader == null)
|
||||
return;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.FileName))
|
||||
FileName = datHeader.FileName;
|
||||
|
||||
@@ -1088,7 +1091,7 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>String containing the new filename</returns>
|
||||
private string CreateOutFileNamesHelper(string outDir, string extension, bool overwrite)
|
||||
{
|
||||
string filename = string.IsNullOrWhiteSpace(FileName) ? Description : FileName;
|
||||
string? filename = string.IsNullOrWhiteSpace(FileName) ? Description : FileName;
|
||||
|
||||
// Strip off the extension if it's a holdover from the DAT
|
||||
if (Utilities.HasValidDatExtension(filename))
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Name or path of the Depot
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
public string? Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use this Depot or not
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
/// <param name="filename">Filename to derive from</param>
|
||||
/// <returns>Filled machine and new filename on success, null on error</returns>
|
||||
private static (Machine?, string?) DeriveMachine(string filename)
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
@@ -95,9 +95,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (file == null)
|
||||
return;
|
||||
|
||||
(var machine, string name) = DeriveMachine(file.Name);
|
||||
if (machine == null)
|
||||
machine = new Machine { Name = Path.GetFileNameWithoutExtension(file.Name) };
|
||||
(var machine, string? name) = DeriveMachine(file.Name);
|
||||
machine ??= new Machine { Name = Path.GetFileNameWithoutExtension(file.Name) };
|
||||
|
||||
machine.Publisher = file.Publisher;
|
||||
machine.Comment = file.Comment;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Create a Files from the current internal information
|
||||
/// <summary>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise</param>
|
||||
private Models.ArchiveDotOrg.Files CreateFiles(bool ignoreblanks)
|
||||
private Models.ArchiveDotOrg.Files? CreateFiles(bool ignoreblanks)
|
||||
{
|
||||
// If we don't have items, we can't do anything
|
||||
if (this.Items == null || !this.Items.Any())
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public ArchiveDotOrg(DatFile datFile)
|
||||
public ArchiveDotOrg(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public AttractMode(DatFile datFile)
|
||||
public AttractMode(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
public class OfflineListInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
[Models.Required]
|
||||
public string? Name { get; set; }
|
||||
public bool? Visible { get; set; }
|
||||
public bool? InNamingOption { get; set; }
|
||||
public bool? Default { get; set; }
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Header.ForcePacking = cmp.ForcePacking.AsPackingFlag();
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (cmp.Name.Contains(" - SuperDAT") && keep)
|
||||
if (cmp.Name?.Contains(" - SuperDAT") == true && keep)
|
||||
Header.Type ??= "SuperDAT";
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
switch (datItem)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
/// <param name="quotes">Enable quotes on read and write, false otherwise</param>
|
||||
public ClrMamePro(DatFile datFile, bool quotes)
|
||||
public ClrMamePro(DatFile? datFile, bool quotes)
|
||||
: base(datFile)
|
||||
{
|
||||
Quotes = quotes;
|
||||
|
||||
@@ -92,8 +92,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
return;
|
||||
|
||||
// Create the machine for copying information
|
||||
string machineName = game.Name.Trim('"');
|
||||
if (machineName.EndsWith(".zip"))
|
||||
string? machineName = game.Name?.Trim('"');
|
||||
if (machineName?.EndsWith(".zip") == true)
|
||||
machineName = System.IO.Path.GetFileNameWithoutExtension(machineName);
|
||||
|
||||
var machine = new Machine { Name = machineName };
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public DosCenter(DatFile datFile)
|
||||
public DosCenter(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
/// <param name="filename">Filename to derive from</param>
|
||||
/// <returns>Filled machine and new filename on success, null on error</returns>
|
||||
private static (Machine?, string?) DeriveMachine(string filename)
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
@@ -95,9 +95,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (row == null)
|
||||
return;
|
||||
|
||||
(var machine, string name) = DeriveMachine(row.Name);
|
||||
if (machine == null)
|
||||
machine = new Machine { Name = Path.GetFileNameWithoutExtension(row.Name) };
|
||||
(var machine, string? name) = DeriveMachine(row.Name);
|
||||
machine ??= new Machine { Name = Path.GetFileNameWithoutExtension(row.Name) };
|
||||
|
||||
var rom = new Rom()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public EverdriveSMDB(DatFile datFile)
|
||||
public EverdriveSMDB(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
/// <param name="filename">Filename to derive from</param>
|
||||
/// <returns>Filled machine and new filename on success, null on error</returns>
|
||||
private static (Machine?, string?) DeriveMachine(string filename)
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
@@ -89,7 +89,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
/// <param name="filename">Filename to derive from</param>
|
||||
/// <returns>ItemType representing the item (Rom by default), ItemType.NULL on error</returns>
|
||||
private static ItemType DeriveItemType(string filename)
|
||||
private static ItemType DeriveItemType(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
@@ -129,12 +129,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var sfv in sfvs)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (sfv == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(sfv.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(sfv.File);
|
||||
(var machine, string? itemName) = DeriveMachine(sfv.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Disk: // Should not happen with CRC32 hashes
|
||||
@@ -179,12 +183,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var md5 in md5s)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (md5 == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(md5.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(md5.File);
|
||||
(var machine, string? itemName) = DeriveMachine(md5.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
@@ -261,12 +269,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var sha1 in sha1s)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (sha1 == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(sha1.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(sha1.File);
|
||||
(var machine, string? itemName) = DeriveMachine(sha1.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
@@ -343,12 +355,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var sha256 in sha256s)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (sha256 == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(sha256.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(sha256.File);
|
||||
(var machine, string? itemName) = DeriveMachine(sha256.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Media:
|
||||
@@ -409,12 +425,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var sha384 in sha384s)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (sha384 == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(sha384.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(sha384.File);
|
||||
(var machine, string? itemName) = DeriveMachine(sha384.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Disk: // Should not happen with SHA-384 hashes
|
||||
@@ -459,12 +479,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var sha512 in sha512s)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (sha512 == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(sha512.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(sha512.File);
|
||||
(var machine, string? itemName) = DeriveMachine(sha512.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Disk: // Should not happen with SHA-512 hashes
|
||||
@@ -509,12 +533,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Loop through and add the items
|
||||
foreach (var spamsum in spamsums)
|
||||
{
|
||||
// Skip if we have an invalid item
|
||||
if (spamsum == null)
|
||||
continue;
|
||||
|
||||
// Get the item type
|
||||
ItemType itemType = DeriveItemType(spamsum.File);
|
||||
if (itemType == ItemType.NULL)
|
||||
continue;
|
||||
|
||||
(var machine, string itemName) = DeriveMachine(spamsum.File);
|
||||
(var machine, string? itemName) = DeriveMachine(spamsum.File);
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Media:
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
@@ -232,6 +232,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -241,7 +243,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -281,6 +283,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -290,7 +294,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -346,6 +350,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -355,7 +361,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -411,6 +417,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -420,7 +428,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -468,6 +476,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -477,7 +487,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -517,6 +527,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -526,7 +538,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
@@ -566,6 +578,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Get the item
|
||||
var item = items[index];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Check for a "null" item
|
||||
item = ProcessNullifiedItem(item);
|
||||
@@ -575,7 +589,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
string name = string.Empty;
|
||||
if (Header.GameName)
|
||||
if (Header.GameName && item.Machine != null)
|
||||
name = $"{item.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
switch (item)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
/// <param name="hash">Type of hash that is associated with this DAT</param>
|
||||
public Hashfile(DatFile datFile, Hash hash)
|
||||
public Hashfile(DatFile? datFile, Hash hash)
|
||||
: base(datFile)
|
||||
{
|
||||
_hash = hash;
|
||||
|
||||
@@ -88,12 +88,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var row in set.Row)
|
||||
foreach (var row in set.Row ?? Array.Empty<Models.Listrom.Row>())
|
||||
{
|
||||
ConvertRow(row, machine, filename, indexId, statsOnly);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,8 +107,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (row == null)
|
||||
return;
|
||||
|
||||
DatItem item = null;
|
||||
|
||||
// Normal CHD
|
||||
if (row.Size == null
|
||||
&& !row.NoGoodDumpKnown
|
||||
@@ -118,7 +114,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
&& (!string.IsNullOrWhiteSpace(row.MD5)
|
||||
|| !string.IsNullOrWhiteSpace(row.SHA1)))
|
||||
{
|
||||
item = new Disk
|
||||
var disk = new Disk
|
||||
{
|
||||
Name = row.Name,
|
||||
ItemStatus = ItemStatus.None,
|
||||
@@ -131,9 +127,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(row.MD5))
|
||||
(item as Disk).MD5 = row.MD5;
|
||||
disk.MD5 = row.MD5;
|
||||
else
|
||||
(item as Disk).SHA1 = row.SHA1;
|
||||
disk.SHA1 = row.SHA1;
|
||||
|
||||
// Now process and add the item
|
||||
disk.CopyMachineInformation(machine);
|
||||
ParseAddHelper(disk, statsOnly);
|
||||
}
|
||||
|
||||
// Normal ROM
|
||||
@@ -141,7 +141,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
&& !row.NoGoodDumpKnown
|
||||
&& !row.Bad)
|
||||
{
|
||||
item = new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = row.Name,
|
||||
Size = Utilities.CleanLong(row.Size),
|
||||
@@ -155,6 +155,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the item
|
||||
rom.CopyMachineInformation(machine);
|
||||
ParseAddHelper(rom, statsOnly);
|
||||
}
|
||||
|
||||
// Bad CHD
|
||||
@@ -164,7 +168,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
&& (!string.IsNullOrWhiteSpace(row.MD5)
|
||||
|| !string.IsNullOrWhiteSpace(row.SHA1)))
|
||||
{
|
||||
item = new Disk
|
||||
var disk = new Disk
|
||||
{
|
||||
Name = row.Name,
|
||||
ItemStatus = ItemStatus.BadDump,
|
||||
@@ -177,16 +181,20 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(row.MD5))
|
||||
(item as Disk).MD5 = row.MD5;
|
||||
disk.MD5 = row.MD5;
|
||||
else
|
||||
(item as Disk).SHA1 = row.SHA1;
|
||||
disk.SHA1 = row.SHA1;
|
||||
|
||||
// Now process and add the item
|
||||
disk.CopyMachineInformation(machine);
|
||||
ParseAddHelper(disk, statsOnly);
|
||||
}
|
||||
|
||||
// Nodump CHD
|
||||
else if (row.Size == null
|
||||
&& row.NoGoodDumpKnown)
|
||||
{
|
||||
item = new Disk
|
||||
var disk = new Disk
|
||||
{
|
||||
Name = row.Name,
|
||||
MD5 = null,
|
||||
@@ -199,6 +207,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the item
|
||||
disk.CopyMachineInformation(machine);
|
||||
ParseAddHelper(disk, statsOnly);
|
||||
}
|
||||
|
||||
// Bad ROM
|
||||
@@ -206,7 +218,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
&& !row.NoGoodDumpKnown
|
||||
&& row.Bad)
|
||||
{
|
||||
item = new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = row.Name,
|
||||
Size = Utilities.CleanLong(row.Size),
|
||||
@@ -220,13 +232,17 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
// Now process and add the item
|
||||
rom.CopyMachineInformation(machine);
|
||||
ParseAddHelper(rom, statsOnly);
|
||||
}
|
||||
|
||||
// Nodump ROM
|
||||
else if (row.Size != null
|
||||
&& row.NoGoodDumpKnown)
|
||||
{
|
||||
item = new Rom
|
||||
var rom = new Rom
|
||||
{
|
||||
Name = row.Name,
|
||||
Size = Utilities.CleanLong(row.Size),
|
||||
@@ -240,11 +256,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Now process and add the item
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
// Now process and add the item
|
||||
rom.CopyMachineInformation(machine);
|
||||
ParseAddHelper(rom, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
@@ -136,10 +136,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (item)
|
||||
{
|
||||
case Disk disk:
|
||||
rows.Add(CreateRow(disk));
|
||||
var diskRow = CreateRow(disk);
|
||||
if (diskRow != null)
|
||||
rows.Add(diskRow);
|
||||
break;
|
||||
case Rom rom:
|
||||
rows.Add(CreateRow(rom));
|
||||
var romRow = CreateRow(rom);
|
||||
if (romRow != null)
|
||||
rows.Add(romRow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public Listrom(DatFile datFile)
|
||||
public Listrom(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Header.MameConfig ??= mame.MameConfig;
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (Header.Name.Contains(" - SuperDAT") && keep)
|
||||
if (Header.Name?.Contains(" - SuperDAT") == true && keep)
|
||||
Header.Type ??= "SuperDAT";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.DatItems.Formats;
|
||||
using SabreTools.IO;
|
||||
|
||||
namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
@@ -45,7 +42,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
switch (datItem)
|
||||
@@ -205,476 +202,6 @@ namespace SabreTools.DatFiles.Formats
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out DAT header using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="xtw">XmlTextWriter to output to</param>
|
||||
private void WriteHeader(XmlTextWriter xtw)
|
||||
{
|
||||
xtw.WriteStartDocument();
|
||||
|
||||
xtw.WriteStartElement("mame");
|
||||
xtw.WriteRequiredAttributeString("build", Header.Name);
|
||||
xtw.WriteOptionalAttributeString("debug", Header.Debug.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("mameconfig", Header.MameConfig);
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="xtw">XmlTextWriter to output to</param>
|
||||
/// <param name="datItem">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private void WriteStartGame(XmlTextWriter xtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state
|
||||
xtw.WriteStartElement("machine");
|
||||
xtw.WriteRequiredAttributeString("name", datItem.Machine.Name);
|
||||
xtw.WriteOptionalAttributeString("sourcefile", datItem.Machine.SourceFile);
|
||||
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
|
||||
xtw.WriteAttributeString("isbios", "yes");
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Device))
|
||||
xtw.WriteAttributeString("isdevice", "yes");
|
||||
if (datItem.Machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
xtw.WriteAttributeString("ismechanical", "yes");
|
||||
|
||||
xtw.WriteOptionalAttributeString("runnable", datItem.Machine.Runnable.FromRunnable());
|
||||
|
||||
if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf);
|
||||
if (!string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteOptionalAttributeString("romof", datItem.Machine.RomOf);
|
||||
if (!string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteOptionalAttributeString("sampleof", datItem.Machine.SampleOf);
|
||||
|
||||
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
|
||||
xtw.WriteOptionalElementString("year", datItem.Machine.Year);
|
||||
xtw.WriteOptionalElementString("manufacturer", datItem.Machine.Manufacturer);
|
||||
xtw.WriteOptionalElementString("history", datItem.Machine.History);
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="xtw">XmlTextWriter to output to</param>
|
||||
private void WriteEndGame(XmlTextWriter xtw)
|
||||
{
|
||||
// End machine
|
||||
xtw.WriteEndElement();
|
||||
|
||||
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 WriteDatItem(XmlTextWriter xtw, DatItem datItem)
|
||||
{
|
||||
// Pre-process the item name
|
||||
ProcessItemName(datItem, true);
|
||||
|
||||
// Build the state
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
var adjuster = datItem as Adjuster;
|
||||
xtw.WriteStartElement("adjuster");
|
||||
xtw.WriteRequiredAttributeString("name", adjuster.Name);
|
||||
xtw.WriteRequiredAttributeString("default", adjuster.Default.FromYesNo());
|
||||
if (adjuster.ConditionsSpecified)
|
||||
{
|
||||
foreach (var adjusterCondition in adjuster.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", adjusterCondition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", adjusterCondition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", adjusterCondition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", adjusterCondition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.BiosSet:
|
||||
var biosSet = datItem as BiosSet;
|
||||
xtw.WriteStartElement("biosset");
|
||||
xtw.WriteRequiredAttributeString("name", biosSet.Name);
|
||||
xtw.WriteRequiredAttributeString("description", biosSet.Description);
|
||||
xtw.WriteOptionalAttributeString("default", biosSet.Default?.ToString().ToLowerInvariant());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Chip:
|
||||
var chip = datItem as Chip;
|
||||
xtw.WriteStartElement("chip");
|
||||
xtw.WriteRequiredAttributeString("name", chip.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", chip.Tag);
|
||||
xtw.WriteRequiredAttributeString("type", chip.ChipType.FromChipType());
|
||||
xtw.WriteOptionalAttributeString("clock", chip.Clock?.ToString());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Condition:
|
||||
var condition = datItem as Condition;
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", condition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", condition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", condition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", condition.Value);
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Configuration:
|
||||
var configuration = datItem as Configuration;
|
||||
xtw.WriteStartElement("configuration");
|
||||
xtw.WriteRequiredAttributeString("name", configuration.Name);
|
||||
xtw.WriteRequiredAttributeString("tag", configuration.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", configuration.Mask);
|
||||
|
||||
if (configuration.ConditionsSpecified)
|
||||
{
|
||||
foreach (var configurationCondition in configuration.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", configurationCondition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", configurationCondition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", configurationCondition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", configurationCondition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (configuration.LocationsSpecified)
|
||||
{
|
||||
foreach (var location in configuration.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("conflocation");
|
||||
xtw.WriteRequiredAttributeString("name", location.Name);
|
||||
xtw.WriteRequiredAttributeString("number", location.Number?.ToString());
|
||||
xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (configuration.SettingsSpecified)
|
||||
{
|
||||
foreach (var setting in configuration.Settings)
|
||||
{
|
||||
xtw.WriteStartElement("confsetting");
|
||||
xtw.WriteRequiredAttributeString("name", setting.Name);
|
||||
xtw.WriteRequiredAttributeString("value", setting.Value);
|
||||
xtw.WriteOptionalAttributeString("default", setting.Default.FromYesNo());
|
||||
if (setting.ConditionsSpecified)
|
||||
{
|
||||
foreach (var confsettingCondition in setting.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", confsettingCondition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", confsettingCondition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", confsettingCondition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", confsettingCondition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Device:
|
||||
var device = datItem as Device;
|
||||
xtw.WriteStartElement("device");
|
||||
xtw.WriteRequiredAttributeString("type", device.DeviceType.FromDeviceType());
|
||||
xtw.WriteOptionalAttributeString("tag", device.Tag);
|
||||
xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage);
|
||||
xtw.WriteOptionalAttributeString("mandatory", device.Mandatory?.ToString());
|
||||
xtw.WriteOptionalAttributeString("interface", device.Interface);
|
||||
if (device.InstancesSpecified)
|
||||
{
|
||||
foreach (var instance in device.Instances)
|
||||
{
|
||||
xtw.WriteStartElement("instance");
|
||||
xtw.WriteRequiredAttributeString("name", instance.Name);
|
||||
xtw.WriteRequiredAttributeString("briefname", instance.BriefName);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (device.ExtensionsSpecified)
|
||||
{
|
||||
foreach (var extension in device.Extensions)
|
||||
{
|
||||
xtw.WriteStartElement("extension");
|
||||
xtw.WriteRequiredAttributeString("name", extension.Name);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.DeviceReference:
|
||||
var deviceRef = datItem as DeviceReference;
|
||||
xtw.WriteStartElement("device_ref");
|
||||
xtw.WriteRequiredAttributeString("name", deviceRef.Name);
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.DipSwitch:
|
||||
var dipSwitch = datItem as DipSwitch;
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
xtw.WriteRequiredAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteRequiredAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", dipSwitch.Mask);
|
||||
if (dipSwitch.ConditionsSpecified)
|
||||
{
|
||||
foreach (var dipSwitchCondition in dipSwitch.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", dipSwitchCondition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", dipSwitchCondition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", dipSwitchCondition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", dipSwitchCondition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.LocationsSpecified)
|
||||
{
|
||||
foreach (var location in dipSwitch.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("diplocation");
|
||||
xtw.WriteRequiredAttributeString("name", location.Name);
|
||||
xtw.WriteRequiredAttributeString("number", location.Number?.ToString());
|
||||
xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.ValuesSpecified)
|
||||
{
|
||||
foreach (var value in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
xtw.WriteRequiredAttributeString("name", value.Name);
|
||||
xtw.WriteRequiredAttributeString("value", value.Value);
|
||||
xtw.WriteOptionalAttributeString("default", value.Default.FromYesNo());
|
||||
if (value.ConditionsSpecified)
|
||||
{
|
||||
foreach (var dipValueCondition in value.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteRequiredAttributeString("tag", dipValueCondition.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", dipValueCondition.Mask);
|
||||
xtw.WriteRequiredAttributeString("relation", dipValueCondition.Relation.FromRelation());
|
||||
xtw.WriteRequiredAttributeString("value", dipValueCondition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
xtw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("merge", disk.MergeTag);
|
||||
xtw.WriteOptionalAttributeString("region", disk.Region);
|
||||
xtw.WriteOptionalAttributeString("index", disk.Index);
|
||||
xtw.WriteOptionalAttributeString("writable", disk.Writable.FromYesNo());
|
||||
if (disk.ItemStatus != ItemStatus.None)
|
||||
xtw.WriteOptionalAttributeString("status", disk.ItemStatus.FromItemStatus(false));
|
||||
xtw.WriteOptionalAttributeString("optional", disk.Optional.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Display:
|
||||
var display = datItem as Display;
|
||||
xtw.WriteStartElement("display");
|
||||
xtw.WriteOptionalAttributeString("tag", display.Tag);
|
||||
xtw.WriteRequiredAttributeString("type", display.DisplayType.FromDisplayType());
|
||||
xtw.WriteOptionalAttributeString("rotate", display.Rotate?.ToString());
|
||||
xtw.WriteOptionalAttributeString("flipx", display.FlipX.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("width", display.Width?.ToString());
|
||||
xtw.WriteOptionalAttributeString("height", display.Height?.ToString());
|
||||
xtw.WriteRequiredAttributeString("refresh", display.Refresh?.ToString("N6"));
|
||||
xtw.WriteOptionalAttributeString("pixclock", display.PixClock?.ToString());
|
||||
xtw.WriteOptionalAttributeString("htotal", display.HTotal?.ToString());
|
||||
xtw.WriteOptionalAttributeString("hbend", display.HBEnd?.ToString());
|
||||
xtw.WriteOptionalAttributeString("hstart", display.HBStart?.ToString());
|
||||
xtw.WriteOptionalAttributeString("vtotal", display.VTotal?.ToString());
|
||||
xtw.WriteOptionalAttributeString("vbend", display.VBEnd?.ToString());
|
||||
xtw.WriteOptionalAttributeString("vbstart", display.VBStart?.ToString());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Driver:
|
||||
var driver = datItem as Driver;
|
||||
xtw.WriteStartElement("driver");
|
||||
xtw.WriteRequiredAttributeString("status", driver.Status.FromSupportStatus());
|
||||
xtw.WriteRequiredAttributeString("emulation", driver.Emulation.FromSupportStatus());
|
||||
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus());
|
||||
xtw.WriteRequiredAttributeString("savestate", driver.SaveState.FromSupported(true));
|
||||
xtw.WriteOptionalAttributeString("requiresartwork", driver.RequiresArtwork.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("unofficial", driver.Unofficial.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("nosoundhardware", driver.NoSoundHardware.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("incomplete", driver.Incomplete.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Feature:
|
||||
var feature = datItem as Feature;
|
||||
xtw.WriteStartElement("feature");
|
||||
xtw.WriteRequiredAttributeString("type", feature.Type.FromFeatureType());
|
||||
xtw.WriteOptionalAttributeString("status", feature.Status.FromFeatureStatus());
|
||||
xtw.WriteOptionalAttributeString("overall", feature.Overall.FromFeatureStatus());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Input:
|
||||
var input = datItem as Input;
|
||||
xtw.WriteStartElement("input");
|
||||
xtw.WriteOptionalAttributeString("service", input.Service.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("tilt", input.Tilt.FromYesNo());
|
||||
xtw.WriteRequiredAttributeString("players", input.Players?.ToString());
|
||||
xtw.WriteOptionalAttributeString("coins", input.Coins?.ToString());
|
||||
if (input.ControlsSpecified)
|
||||
{
|
||||
foreach (var control in input.Controls)
|
||||
{
|
||||
xtw.WriteStartElement("control");
|
||||
xtw.WriteRequiredAttributeString("type", control.ControlType.FromControlType());
|
||||
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
||||
xtw.WriteOptionalAttributeString("reqbuttons", control.RequiredButtons?.ToString());
|
||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
||||
xtw.WriteOptionalAttributeString("keydelta", control.KeyDelta?.ToString());
|
||||
xtw.WriteOptionalAttributeString("reverse", control.Reverse.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("ways", control.Ways);
|
||||
xtw.WriteOptionalAttributeString("ways2", control.Ways2);
|
||||
xtw.WriteOptionalAttributeString("ways3", control.Ways3);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Port:
|
||||
var port = datItem as Port;
|
||||
xtw.WriteStartElement("port");
|
||||
xtw.WriteRequiredAttributeString("tag", port.Tag);
|
||||
if (port.AnalogsSpecified)
|
||||
{
|
||||
foreach (var analog in port.Analogs)
|
||||
{
|
||||
xtw.WriteStartElement("analog");
|
||||
xtw.WriteRequiredAttributeString("mask", analog.Mask);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.RamOption:
|
||||
var ramOption = datItem as RamOption;
|
||||
xtw.WriteStartElement("ramoption");
|
||||
xtw.WriteRequiredAttributeString("name", ramOption.Name);
|
||||
xtw.WriteOptionalAttributeString("default", ramOption.Default.FromYesNo());
|
||||
xtw.WriteRaw(ramOption.Content ?? string.Empty);
|
||||
xtw.WriteFullEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
xtw.WriteStartElement("rom");
|
||||
xtw.WriteRequiredAttributeString("name", rom.Name);
|
||||
xtw.WriteOptionalAttributeString("bios", rom.Bios);
|
||||
xtw.WriteRequiredAttributeString("size", rom.Size?.ToString());
|
||||
xtw.WriteOptionalAttributeString("crc", rom.CRC?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha1", rom.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("merge", rom.MergeTag);
|
||||
xtw.WriteOptionalAttributeString("region", rom.Region);
|
||||
xtw.WriteOptionalAttributeString("offset", rom.Offset);
|
||||
if (rom.ItemStatus != ItemStatus.None)
|
||||
xtw.WriteOptionalAttributeString("status", rom.ItemStatus.FromItemStatus(false));
|
||||
xtw.WriteOptionalAttributeString("optional", rom.Optional.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Sample:
|
||||
var sample = datItem as Sample;
|
||||
xtw.WriteStartElement("sample");
|
||||
xtw.WriteRequiredAttributeString("name", sample.Name);
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Slot:
|
||||
var slot = datItem as Slot;
|
||||
xtw.WriteStartElement("slot");
|
||||
xtw.WriteRequiredAttributeString("name", slot.Name);
|
||||
if (slot.SlotOptionsSpecified)
|
||||
{
|
||||
foreach (var slotOption in slot.SlotOptions)
|
||||
{
|
||||
xtw.WriteStartElement("slotoption");
|
||||
xtw.WriteRequiredAttributeString("name", slotOption.Name);
|
||||
xtw.WriteRequiredAttributeString("devname", slotOption.DeviceName);
|
||||
xtw.WriteOptionalAttributeString("default", slotOption.Default.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.SoftwareList:
|
||||
var softwareList = datItem as DatItems.Formats.SoftwareList;
|
||||
xtw.WriteStartElement("softwarelist");
|
||||
xtw.WriteRequiredAttributeString("tag", softwareList.Tag);
|
||||
xtw.WriteRequiredAttributeString("name", softwareList.Name);
|
||||
if (softwareList.Status != SoftwareListStatus.None)
|
||||
xtw.WriteRequiredAttributeString("status", softwareList.Status.FromSoftwareListStatus());
|
||||
xtw.WriteOptionalAttributeString("filter", softwareList.Filter);
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Sound:
|
||||
var sound = datItem as Sound;
|
||||
xtw.WriteStartElement("sound");
|
||||
xtw.WriteRequiredAttributeString("channels", sound.Channels?.ToString());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
}
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write out DAT footer using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="xtw">XmlTextWriter to output to</param>
|
||||
private void WriteFooter(XmlTextWriter xtw)
|
||||
{
|
||||
// End machine
|
||||
xtw.WriteEndElement();
|
||||
|
||||
// End mame
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
#region Converters
|
||||
|
||||
/// <summary>
|
||||
@@ -841,7 +368,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
/// Create a GameBase from the current internal information
|
||||
/// <summary>
|
||||
private Models.Listxml.GameBase? CreateGame(Machine machine)
|
||||
private Models.Listxml.GameBase CreateGame(Machine machine)
|
||||
{
|
||||
var game = new Models.Listxml.Machine
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public Listxml(DatFile datFile)
|
||||
public Listxml(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
ConvertSubheader(header.RomCenter);
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (header.Name.Contains(" - SuperDAT") && keep)
|
||||
if (header.Name?.Contains(" - SuperDAT") == true && keep)
|
||||
Header.Type ??= "SuperDAT";
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
private void ConvertGame(Models.Logiqx.GameBase game, string filename, int indexId, bool statsOnly, string dirname = null)
|
||||
private void ConvertGame(Models.Logiqx.GameBase game, string filename, int indexId, bool statsOnly, string? dirname = null)
|
||||
{
|
||||
// If the game is missing, we can't do anything
|
||||
if (game == null)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
switch (datItem)
|
||||
@@ -385,7 +385,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
/// Create a GameBase from the current internal information
|
||||
/// <summary>
|
||||
private Models.Logiqx.GameBase? CreateGame(Machine machine)
|
||||
private Models.Logiqx.GameBase CreateGame(Machine machine)
|
||||
{
|
||||
Models.Logiqx.GameBase game = _deprecated ? new Models.Logiqx.Game() : new Models.Logiqx.Machine();
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
/// <param name="deprecated">True if the output uses "game", false if the output uses "machine"</param>
|
||||
public Logiqx(DatFile datFile, bool deprecated)
|
||||
public Logiqx(DatFile? datFile, bool deprecated)
|
||||
: base(datFile)
|
||||
{
|
||||
_deprecated = deprecated;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
internal partial class Missfile : DatFile
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
// TODO: Check required fields
|
||||
return null;
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
StreamWriter sw = new(fs, new UTF8Encoding(false));
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
string? lastgame = null;
|
||||
|
||||
// Use a sorted list of games to output
|
||||
foreach (string key in Items.SortedKeys)
|
||||
@@ -86,7 +86,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="datItem">DatItem object to be output</param>
|
||||
/// <param name="lastgame">The name of the last game to be output</param>
|
||||
private void WriteDatItem(StreamWriter sw, DatItem datItem, string lastgame)
|
||||
private void WriteDatItem(StreamWriter sw, DatItem datItem, string? lastgame)
|
||||
{
|
||||
// Process the item name
|
||||
ProcessItemName(datItem, false, forceRomName: false);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public Missfile(DatFile datFile)
|
||||
public Missfile(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
ConvertHeader(dat);
|
||||
|
||||
// Convert the configuration to the internal format
|
||||
ConvertConfiguration(dat.Configuration, keep);
|
||||
ConvertConfiguration(dat?.Configuration, keep);
|
||||
|
||||
// Convert the games to the internal format
|
||||
ConvertGames(dat?.Games, filename, indexId, statsOnly);
|
||||
@@ -78,7 +78,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Header.RomTitle = config.RomTitle;
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (config.DatName.Contains(" - SuperDAT") && keep)
|
||||
if (config.DatName?.Contains(" - SuperDAT") == true && keep)
|
||||
Header.Type ??= "SuperDAT";
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private void ConvertCanOpen(Models.OfflineList.CanOpen? canOpen)
|
||||
{
|
||||
// If the canOpen is missing, we can't do anything
|
||||
if (canOpen == null)
|
||||
if (canOpen?.Extension == null)
|
||||
return;
|
||||
|
||||
Header.CanOpen = new List<string>(canOpen.Extension);
|
||||
@@ -354,7 +354,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
/// <param name="containsItems">True if there were any items in the array, false otherwise</param>
|
||||
private void ConvertFiles(Models.OfflineList.Files? files, Machine machine, long? size, string releaseNumber, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
||||
private void ConvertFiles(Models.OfflineList.Files? files, Machine machine, long? size, string? releaseNumber, string filename, int indexId, bool statsOnly, ref bool containsItems)
|
||||
{
|
||||
// If the files array is missing, we can't do anything
|
||||
if (files?.RomCRC == null || !files.RomCRC.Any())
|
||||
@@ -371,6 +371,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
var item = new Rom
|
||||
{
|
||||
Name = name,
|
||||
Size = size,
|
||||
CRC = crc.Content,
|
||||
ItemStatus = ItemStatus.None,
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private Models.OfflineList.Infos? CreateInfos()
|
||||
{
|
||||
// If we don't have infos, we can't do anything
|
||||
if (!Header.InfosSpecified)
|
||||
if (!Header.InfosSpecified || Header.Infos == null)
|
||||
return null;
|
||||
|
||||
var infos = new Models.OfflineList.Infos();
|
||||
@@ -256,7 +256,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private Models.OfflineList.CanOpen? CreateCanOpen()
|
||||
{
|
||||
// If we don't have a canopen, we can't do anything
|
||||
if (!Header.CanOpenSpecified)
|
||||
if (!Header.CanOpenSpecified || Header.CanOpen == null)
|
||||
return null;
|
||||
|
||||
var canOpen = new Models.OfflineList.CanOpen
|
||||
@@ -360,12 +360,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
/// Create a Machine from the current internal information
|
||||
/// <summary>
|
||||
private Models.OfflineList.Game? CreateGame(Machine machine)
|
||||
private Models.OfflineList.Game CreateGame(Machine machine)
|
||||
{
|
||||
// If we don't have a machine, we can't do anything
|
||||
if (machine == null)
|
||||
return null;
|
||||
|
||||
|
||||
var game = new Models.OfflineList.Game
|
||||
{
|
||||
//ImageNumber = machine.ImageNumber, // TODO: Add to internal model
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public OfflineList(DatFile datFile)
|
||||
public OfflineList(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
private void ConvertSoftware(Models.OpenMSX.Software software, string filename, int indexId, bool statsOnly, string dirname = null)
|
||||
private void ConvertSoftware(Models.OpenMSX.Software software, string filename, int indexId, bool statsOnly)
|
||||
{
|
||||
// If the software is missing, we can't do anything
|
||||
if (software == null)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
|
||||
@@ -149,9 +149,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
private static Models.OpenMSX.Dump CreateDump(Rom item)
|
||||
{
|
||||
|
||||
Models.OpenMSX.Original original = null;
|
||||
if (item.OriginalSpecified)
|
||||
Models.OpenMSX.Original? original = null;
|
||||
if (item.OriginalSpecified && item.Original != null)
|
||||
{
|
||||
original = new Models.OpenMSX.Original { Content = item.Original.Content };
|
||||
if (item.Original.Value != null)
|
||||
|
||||
@@ -40,7 +40,7 @@ The softwaredb.xml file contains information about rom mapper types
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public OpenMSX(DatFile datFile)
|
||||
public OpenMSX(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Create a Games from the current internal information
|
||||
/// <summary>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise</param>
|
||||
private Models.RomCenter.Games CreateGames(bool ignoreblanks)
|
||||
private Models.RomCenter.Games? CreateGames(bool ignoreblanks)
|
||||
{
|
||||
// If we don't have items, we can't do anything
|
||||
if (this.Items == null || !this.Items.Any())
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public RomCenter(DatFile datFile)
|
||||
public RomCenter(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public SabreJSON(DatFile datFile)
|
||||
public SabreJSON(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
@@ -92,7 +92,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Read in the header and apply any new fields
|
||||
jtr.Read();
|
||||
JsonSerializer js = new();
|
||||
DatHeader header = js.Deserialize<DatHeader>(jtr);
|
||||
DatHeader? header = js.Deserialize<DatHeader>(jtr);
|
||||
Header.ConditionalCopy(header);
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Read in the machine array
|
||||
jtr.Read();
|
||||
JsonSerializer js = new();
|
||||
JArray machineArray = js.Deserialize<JArray>(jtr);
|
||||
JArray? machineArray = js.Deserialize<JArray>(jtr);
|
||||
|
||||
// Loop through each machine object and process
|
||||
foreach (JObject machineObj in machineArray)
|
||||
foreach (JObject machineObj in machineArray ?? new JArray())
|
||||
{
|
||||
ReadMachine(machineObj, statsOnly, filename, indexId);
|
||||
}
|
||||
@@ -135,11 +135,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
return;
|
||||
|
||||
// Prepare internal variables
|
||||
Machine machine = null;
|
||||
Machine? machine = null;
|
||||
|
||||
// Read the machine info, if possible
|
||||
if (machineObj.ContainsKey("machine"))
|
||||
machine = machineObj["machine"].ToObject<Machine>();
|
||||
machine = machineObj["machine"]?.ToObject<Machine>();
|
||||
|
||||
// Read items, if possible
|
||||
if (machineObj.ContainsKey("items"))
|
||||
@@ -155,7 +155,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="machine">Machine information to add to the parsed items</param>
|
||||
private void ReadItems(
|
||||
JArray itemsArr,
|
||||
JArray? itemsArr,
|
||||
bool statsOnly,
|
||||
|
||||
// Standard Dat parsing
|
||||
@@ -163,7 +163,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
Machine machine)
|
||||
Machine? machine)
|
||||
{
|
||||
// If the array is invalid, skip
|
||||
if (itemsArr == null)
|
||||
@@ -193,19 +193,22 @@ namespace SabreTools.DatFiles.Formats
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
Machine machine)
|
||||
Machine? machine)
|
||||
{
|
||||
// If we have an empty item, skip it
|
||||
if (itemObj == null)
|
||||
return;
|
||||
|
||||
// Prepare internal variables
|
||||
DatItem datItem = null;
|
||||
DatItem? datItem = null;
|
||||
|
||||
// Read the datitem info, if possible
|
||||
if (itemObj.ContainsKey("datitem"))
|
||||
{
|
||||
JToken datItemObj = itemObj["datitem"];
|
||||
JToken? datItemObj = itemObj["datitem"];
|
||||
if (datItemObj == null)
|
||||
return;
|
||||
|
||||
switch (datItemObj.Value<string>("type").AsItemType())
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
@@ -367,7 +370,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteHeader(jtw);
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
string? lastgame = null;
|
||||
|
||||
// Use a sorted list of games to output
|
||||
foreach (string key in Items.SortedKeys)
|
||||
@@ -523,7 +526,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
jtw.Flush();
|
||||
}
|
||||
|
||||
|
||||
// https://github.com/dotnet/runtime/issues/728
|
||||
private class BaseFirstContractResolver : DefaultContractResolver
|
||||
{
|
||||
@@ -535,9 +538,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
||||
{
|
||||
return base.CreateProperties(type, memberSerialization)
|
||||
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count()).ToList();
|
||||
.Where(p => p != null)
|
||||
.OrderBy(p => BaseTypesAndSelf(p.DeclaringType).Count())
|
||||
.ToList();
|
||||
|
||||
static IEnumerable<Type> BaseTypesAndSelf(Type t)
|
||||
static IEnumerable<Type?> BaseTypesAndSelf(Type? t)
|
||||
{
|
||||
while (t != null)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public SabreXML(DatFile datFile)
|
||||
public SabreXML(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
||||
{
|
||||
// Prepare all internal variables
|
||||
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
|
||||
XmlReader? xtr = XmlReader.Create(filename, new XmlReaderSettings
|
||||
{
|
||||
CheckCharacters = false,
|
||||
DtdProcessing = DtdProcessing.Ignore,
|
||||
@@ -58,7 +58,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
case "header":
|
||||
XmlSerializer xs = new(typeof(DatHeader));
|
||||
DatHeader header = xs.Deserialize(xtr.ReadSubtree()) as DatHeader;
|
||||
DatHeader? header = xs.Deserialize(xtr.ReadSubtree()) as DatHeader;
|
||||
Header.ConditionalCopy(header);
|
||||
xtr.Skip();
|
||||
break;
|
||||
@@ -78,12 +78,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
catch (Exception ex) when (!throwOnError)
|
||||
{
|
||||
logger.Warning(ex, $"Exception found while parsing '{filename}'");
|
||||
|
||||
|
||||
// For XML errors, just skip the affected node
|
||||
xtr?.Read();
|
||||
}
|
||||
|
||||
xtr.Dispose();
|
||||
xtr?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,7 +100,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return;
|
||||
|
||||
// Prepare internal variables
|
||||
Machine machine = null;
|
||||
Machine? machine = null;
|
||||
|
||||
// Otherwise, read the directory
|
||||
xtr.MoveToContent();
|
||||
@@ -117,7 +117,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
case "machine":
|
||||
XmlSerializer xs = new(typeof(Machine));
|
||||
machine = xs.Deserialize(xtr.ReadSubtree()) as Machine;
|
||||
machine = xs?.Deserialize(xtr.ReadSubtree()) as Machine;
|
||||
xtr.Skip();
|
||||
break;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
private void ReadFiles(XmlReader xtr, Machine machine, bool statsOnly, string filename, int indexId)
|
||||
private void ReadFiles(XmlReader xtr, Machine? machine, bool statsOnly, string filename, int indexId)
|
||||
{
|
||||
// If the reader is invalid, skip
|
||||
if (xtr == null)
|
||||
@@ -163,10 +163,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
case "datitem":
|
||||
XmlSerializer xs = new(typeof(DatItem));
|
||||
DatItem item = xs.Deserialize(xtr.ReadSubtree()) as DatItem;
|
||||
item.CopyMachineInformation(machine);
|
||||
item.Source = new Source { Name = filename, Index = indexId };
|
||||
ParseAddHelper(item, statsOnly);
|
||||
if (xs.Deserialize(xtr.ReadSubtree()) is DatItem item)
|
||||
{
|
||||
item.CopyMachineInformation(machine);
|
||||
item.Source = new Source { Name = filename, Index = indexId };
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
xtr.Skip();
|
||||
break;
|
||||
default:
|
||||
@@ -202,7 +204,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteHeader(xtw);
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
string? lastgame = null;
|
||||
|
||||
// Use a sorted list of games to output
|
||||
foreach (string key in Items.SortedKeys)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
// Read item values
|
||||
DatItem item = null;
|
||||
DatItem? item = null;
|
||||
switch (row.Type.AsItemType())
|
||||
{
|
||||
case ItemType.Disk:
|
||||
@@ -137,8 +137,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
// Now process and add the item
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
if (item != null)
|
||||
{
|
||||
item.CopyMachineInformation(machine);
|
||||
ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
/// <param name="delim">Delimiter for parsing individual lines</param>
|
||||
public SeparatedValue(DatFile datFile, char delim)
|
||||
public SeparatedValue(DatFile? datFile, char delim)
|
||||
: base(datFile)
|
||||
{
|
||||
_delim = delim;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Header.Comment ??= softwarelist.Notes;
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (Header.Name.Contains(" - SuperDAT") && keep)
|
||||
if (Header.Name?.Contains(" - SuperDAT") == true && keep)
|
||||
Header.Type ??= "SuperDAT";
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
protected override List<DatItemField>? GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new();
|
||||
var missingFields = new List<DatItemField>();
|
||||
|
||||
switch (datItem.ItemType)
|
||||
switch (datItem)
|
||||
{
|
||||
case ItemType.DipSwitch:
|
||||
DipSwitch dipSwitch = datItem as DipSwitch;
|
||||
case DipSwitch dipSwitch:
|
||||
if (!dipSwitch.PartSpecified)
|
||||
{
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
@@ -63,8 +62,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
break;
|
||||
|
||||
case ItemType.Disk:
|
||||
Disk disk = datItem as Disk;
|
||||
case Disk disk:
|
||||
if (!disk.PartSpecified)
|
||||
{
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
@@ -90,14 +88,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case ItemType.Info:
|
||||
Info info = datItem as Info;
|
||||
case Info info:
|
||||
if (string.IsNullOrWhiteSpace(info.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
Rom rom = datItem as Rom;
|
||||
case Rom rom:
|
||||
if (!rom.PartSpecified)
|
||||
{
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
@@ -124,9 +120,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
break;
|
||||
|
||||
case ItemType.SharedFeature:
|
||||
SharedFeature sharedFeature = datItem as SharedFeature;
|
||||
if (string.IsNullOrWhiteSpace(sharedFeature.Name))
|
||||
case SharedFeature sharedFeat:
|
||||
if (string.IsNullOrWhiteSpace(sharedFeat.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
default:
|
||||
@@ -260,7 +255,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <summary>
|
||||
/// Create a Software from the current internal information
|
||||
/// <summary>
|
||||
private Models.SoftwareList.Software? CreateSoftware(Machine machine)
|
||||
private Models.SoftwareList.Software CreateSoftware(Machine machine)
|
||||
{
|
||||
var software = new Models.SoftwareList.Software
|
||||
{
|
||||
@@ -467,7 +462,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static List<Models.SoftwareList.Part> SantitizeParts(List<Models.SoftwareList.Part> parts)
|
||||
{
|
||||
// If we have no parts, we can't do anything
|
||||
if (parts == null || !parts.Any())
|
||||
if (!parts.Any())
|
||||
return parts;
|
||||
|
||||
var grouped = parts.GroupBy(p => p.Name);
|
||||
@@ -521,7 +516,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static List<Models.SoftwareList.DataArea> SantitizeDataAreas(List<Models.SoftwareList.DataArea> dataAreas)
|
||||
{
|
||||
// If we have no DataAreas, we can't do anything
|
||||
if (dataAreas == null || !dataAreas.Any())
|
||||
if (!dataAreas.Any())
|
||||
return dataAreas;
|
||||
|
||||
var grouped = dataAreas.GroupBy(p => p.Name);
|
||||
@@ -558,7 +553,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static List<Models.SoftwareList.DiskArea> SantitizeDiskAreas(List<Models.SoftwareList.DiskArea> diskAreas)
|
||||
{
|
||||
// If we have no DiskAreas, we can't do anything
|
||||
if (diskAreas == null || !diskAreas.Any())
|
||||
if (!diskAreas.Any())
|
||||
return diskAreas;
|
||||
|
||||
var grouped = diskAreas.GroupBy(p => p.Name);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public SoftwareList(DatFile datFile)
|
||||
public SoftwareList(DatFile? datFile)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SabreTools.DatFiles
|
||||
/// This will help handle extremely large sets
|
||||
/// </remarks>
|
||||
[JsonObject("items"), XmlRoot("items")]
|
||||
public class ItemDictionary : IDictionary<string, ConcurrentList<DatItem>>
|
||||
public class ItemDictionary : IDictionary<string, ConcurrentList<DatItem>?>
|
||||
{
|
||||
#region Private instance variables
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Internal dictionary for the class
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, ConcurrentList<DatItem>> items;
|
||||
private readonly ConcurrentDictionary<string, ConcurrentList<DatItem>?> items;
|
||||
|
||||
/// <summary>
|
||||
/// Lock for statistics calculation
|
||||
@@ -385,7 +385,7 @@ namespace SabreTools.DatFiles
|
||||
/// Passthrough to access the file dictionary
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to reference</param>
|
||||
public ConcurrentList<DatItem> this[string key]
|
||||
public ConcurrentList<DatItem>? this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -427,7 +427,7 @@ namespace SabreTools.DatFiles
|
||||
return;
|
||||
|
||||
// Now add the value
|
||||
items[key].Add(value);
|
||||
items[key]!.Add(value);
|
||||
|
||||
// Now update the statistics
|
||||
AddItemStatistics(value);
|
||||
@@ -439,7 +439,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to add to</param>
|
||||
/// <param name="value">Value to add to the dictionary</param>
|
||||
public void Add(string key, ConcurrentList<DatItem> value)
|
||||
public void Add(string key, ConcurrentList<DatItem>? value)
|
||||
{
|
||||
AddRange(key, value);
|
||||
}
|
||||
@@ -460,135 +460,135 @@ namespace SabreTools.DatFiles
|
||||
RemovedCount++;
|
||||
|
||||
// Now we do different things for each item type
|
||||
switch (item.ItemType)
|
||||
switch (item)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
case Adjuster:
|
||||
AdjusterCount++;
|
||||
break;
|
||||
case ItemType.Analog:
|
||||
case Analog:
|
||||
AnalogCount++;
|
||||
break;
|
||||
case ItemType.Archive:
|
||||
case Archive:
|
||||
ArchiveCount++;
|
||||
break;
|
||||
case ItemType.BiosSet:
|
||||
case BiosSet:
|
||||
BiosSetCount++;
|
||||
break;
|
||||
case ItemType.Chip:
|
||||
case Chip:
|
||||
ChipCount++;
|
||||
break;
|
||||
case ItemType.Condition:
|
||||
case Condition:
|
||||
ConditionCount++;
|
||||
break;
|
||||
case ItemType.Configuration:
|
||||
case Configuration:
|
||||
ConfigurationCount++;
|
||||
break;
|
||||
case ItemType.DataArea:
|
||||
case DataArea:
|
||||
DataAreaCount++;
|
||||
break;
|
||||
case ItemType.Device:
|
||||
case Device:
|
||||
DeviceCount++;
|
||||
break;
|
||||
case ItemType.DeviceReference:
|
||||
case DeviceReference:
|
||||
DeviceReferenceCount++;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
case DipSwitch:
|
||||
DipSwitchCount++;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
case Disk disk:
|
||||
DiskCount++;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.DiskArea:
|
||||
case DiskArea:
|
||||
DiskAreaCount++;
|
||||
break;
|
||||
case ItemType.Display:
|
||||
case Display:
|
||||
DisplayCount++;
|
||||
break;
|
||||
case ItemType.Driver:
|
||||
case Driver:
|
||||
DriverCount++;
|
||||
break;
|
||||
case ItemType.Feature:
|
||||
case Feature:
|
||||
FeatureCount++;
|
||||
break;
|
||||
case ItemType.Info:
|
||||
case Info:
|
||||
InfoCount++;
|
||||
break;
|
||||
case ItemType.Input:
|
||||
case Input:
|
||||
InputCount++;
|
||||
break;
|
||||
case ItemType.Media:
|
||||
case Media media:
|
||||
MediaCount++;
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace((item as Media).SpamSum) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Part:
|
||||
case Part:
|
||||
PartCount++;
|
||||
break;
|
||||
case ItemType.PartFeature:
|
||||
case PartFeature:
|
||||
PartFeatureCount++;
|
||||
break;
|
||||
case ItemType.Port:
|
||||
case Port:
|
||||
PortCount++;
|
||||
break;
|
||||
case ItemType.RamOption:
|
||||
case RamOption:
|
||||
RamOptionCount++;
|
||||
break;
|
||||
case ItemType.Release:
|
||||
case Release:
|
||||
ReleaseCount++;
|
||||
break;
|
||||
case ItemType.ReleaseDetails:
|
||||
case ReleaseDetails:
|
||||
ReleaseDetailsCount++;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
case Rom rom:
|
||||
RomCount++;
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += (item as Rom).Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace((item as Rom).SpamSum) ? 0 : 1);
|
||||
TotalSize += rom.Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
case Sample:
|
||||
SampleCount++;
|
||||
break;
|
||||
case ItemType.Serials:
|
||||
case Serials:
|
||||
SerialsCount++;
|
||||
break;
|
||||
case ItemType.SharedFeature:
|
||||
case SharedFeature:
|
||||
SharedFeatureCount++;
|
||||
break;
|
||||
case ItemType.Slot:
|
||||
case Slot:
|
||||
SlotCount++;
|
||||
break;
|
||||
case ItemType.SoftwareList:
|
||||
case SoftwareList:
|
||||
SoftwareListCount++;
|
||||
break;
|
||||
case ItemType.Sound:
|
||||
case Sound:
|
||||
SoundCount++;
|
||||
break;
|
||||
case ItemType.SourceDetails:
|
||||
case SourceDetails:
|
||||
SourceDetailsCount++;
|
||||
break;
|
||||
}
|
||||
@@ -600,7 +600,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to add to</param>
|
||||
/// <param name="value">Value to add to the dictionary</param>
|
||||
public void AddRange(string key, ConcurrentList<DatItem> value)
|
||||
public void AddRange(string key, ConcurrentList<DatItem>? value)
|
||||
{
|
||||
// Explicit lock for some weird corner cases
|
||||
lock (key)
|
||||
@@ -613,7 +613,7 @@ namespace SabreTools.DatFiles
|
||||
EnsureKey(key);
|
||||
|
||||
// Now add the value
|
||||
items[key].AddRange(value);
|
||||
items[key]!.AddRange(value);
|
||||
|
||||
// Now update the statistics
|
||||
foreach (DatItem item in value)
|
||||
@@ -694,8 +694,8 @@ namespace SabreTools.DatFiles
|
||||
// Explicit lock for some weird corner cases
|
||||
lock (key)
|
||||
{
|
||||
if (items.ContainsKey(key))
|
||||
return items[key].Contains(value);
|
||||
if (items.ContainsKey(key) && items[key] != null)
|
||||
return items[key]!.Contains(value);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -721,7 +721,7 @@ namespace SabreTools.DatFiles
|
||||
lock (key)
|
||||
{
|
||||
// Get the list, if possible
|
||||
ConcurrentList<DatItem> fi = items[key];
|
||||
ConcurrentList<DatItem>? fi = items[key];
|
||||
if (fi == null)
|
||||
return new ConcurrentList<DatItem>();
|
||||
|
||||
@@ -743,11 +743,11 @@ namespace SabreTools.DatFiles
|
||||
lock (key)
|
||||
{
|
||||
// If the key doesn't exist, return
|
||||
if (!ContainsKey(key))
|
||||
if (!ContainsKey(key) || items[key] == null)
|
||||
return false;
|
||||
|
||||
// Remove the statistics first
|
||||
foreach (DatItem item in items[key])
|
||||
foreach (DatItem item in items[key]!)
|
||||
{
|
||||
RemoveItemStatistics(item);
|
||||
}
|
||||
@@ -768,13 +768,13 @@ namespace SabreTools.DatFiles
|
||||
lock (key)
|
||||
{
|
||||
// If the key and value doesn't exist, return
|
||||
if (!Contains(key, value))
|
||||
if (!Contains(key, value) || items[key] == null)
|
||||
return false;
|
||||
|
||||
// Remove the statistics first
|
||||
RemoveItemStatistics(value);
|
||||
|
||||
return items[key].Remove(value);
|
||||
return items[key]!.Remove(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,11 +785,11 @@ namespace SabreTools.DatFiles
|
||||
public bool Reset(string key)
|
||||
{
|
||||
// If the key doesn't exist, return
|
||||
if (!ContainsKey(key))
|
||||
if (!ContainsKey(key) || items[key] == null)
|
||||
return false;
|
||||
|
||||
// Remove the statistics first
|
||||
foreach (DatItem item in items[key])
|
||||
foreach (DatItem item in items[key]!)
|
||||
{
|
||||
RemoveItemStatistics(item);
|
||||
}
|
||||
@@ -828,124 +828,124 @@ namespace SabreTools.DatFiles
|
||||
RemovedCount--;
|
||||
|
||||
// Now we do different things for each item type
|
||||
switch (item.ItemType)
|
||||
switch (item)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
case Adjuster:
|
||||
AdjusterCount--;
|
||||
break;
|
||||
case ItemType.Analog:
|
||||
case Analog:
|
||||
AnalogCount--;
|
||||
break;
|
||||
case ItemType.Archive:
|
||||
case Archive:
|
||||
ArchiveCount--;
|
||||
break;
|
||||
case ItemType.BiosSet:
|
||||
case BiosSet:
|
||||
BiosSetCount--;
|
||||
break;
|
||||
case ItemType.Chip:
|
||||
case Chip:
|
||||
ChipCount--;
|
||||
break;
|
||||
case ItemType.Condition:
|
||||
case Condition:
|
||||
ConditionCount--;
|
||||
break;
|
||||
case ItemType.Configuration:
|
||||
case Configuration:
|
||||
ConfigurationCount--;
|
||||
break;
|
||||
case ItemType.DataArea:
|
||||
case DataArea:
|
||||
DataAreaCount--;
|
||||
break;
|
||||
case ItemType.Device:
|
||||
case Device:
|
||||
DeviceCount--;
|
||||
break;
|
||||
case ItemType.DeviceReference:
|
||||
case DeviceReference:
|
||||
DeviceReferenceCount--;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
case DipSwitch:
|
||||
DipSwitchCount--;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
case Disk disk:
|
||||
DiskCount--;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.DiskArea:
|
||||
case DiskArea:
|
||||
DiskAreaCount--;
|
||||
break;
|
||||
case ItemType.Display:
|
||||
case Display:
|
||||
DisplayCount--;
|
||||
break;
|
||||
case ItemType.Driver:
|
||||
case Driver:
|
||||
DriverCount--;
|
||||
break;
|
||||
case ItemType.Feature:
|
||||
case Feature:
|
||||
FeatureCount--;
|
||||
break;
|
||||
case ItemType.Info:
|
||||
case Info:
|
||||
InfoCount--;
|
||||
break;
|
||||
case ItemType.Input:
|
||||
case Input:
|
||||
InputCount--;
|
||||
break;
|
||||
case ItemType.Media:
|
||||
case Media media:
|
||||
MediaCount--;
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Part:
|
||||
case Part:
|
||||
PartCount--;
|
||||
break;
|
||||
case ItemType.PartFeature:
|
||||
case PartFeature:
|
||||
PartFeatureCount--;
|
||||
break;
|
||||
case ItemType.Port:
|
||||
case Port:
|
||||
PortCount--;
|
||||
break;
|
||||
case ItemType.RamOption:
|
||||
case RamOption:
|
||||
RamOptionCount--;
|
||||
break;
|
||||
case ItemType.Release:
|
||||
case Release:
|
||||
ReleaseCount--;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
case Rom rom:
|
||||
RomCount--;
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= (item as Rom).Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
TotalSize -= rom.Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
case Sample:
|
||||
SampleCount--;
|
||||
break;
|
||||
case ItemType.SharedFeature:
|
||||
case SharedFeature:
|
||||
SharedFeatureCount--;
|
||||
break;
|
||||
case ItemType.Slot:
|
||||
case Slot:
|
||||
SlotCount--;
|
||||
break;
|
||||
case ItemType.SoftwareList:
|
||||
case SoftwareList:
|
||||
SoftwareListCount--;
|
||||
break;
|
||||
case ItemType.Sound:
|
||||
case Sound:
|
||||
SoundCount--;
|
||||
break;
|
||||
}
|
||||
@@ -963,7 +963,7 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
bucketedBy = ItemKey.NULL;
|
||||
mergedBy = DedupeType.None;
|
||||
items = new ConcurrentDictionary<string, ConcurrentList<DatItem>>();
|
||||
items = new ConcurrentDictionary<string, ConcurrentList<DatItem>?>();
|
||||
logger = new Logger(this);
|
||||
}
|
||||
|
||||
@@ -1000,11 +1000,13 @@ namespace SabreTools.DatFiles
|
||||
Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k =>
|
||||
{
|
||||
string key = oldkeys[k];
|
||||
if (this[key] == null)
|
||||
Remove(key);
|
||||
|
||||
// Now add each of the roms to their respective keys
|
||||
for (int i = 0; i < this[key].Count; i++)
|
||||
for (int i = 0; i < this[key]!.Count; i++)
|
||||
{
|
||||
DatItem item = this[key][i];
|
||||
DatItem item = this[key]![i];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
@@ -1021,7 +1023,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// If the key is now empty, remove it
|
||||
if (this[key].Count == 0)
|
||||
if (this[key]!.Count == 0)
|
||||
Remove(key);
|
||||
});
|
||||
}
|
||||
@@ -1059,10 +1061,11 @@ namespace SabreTools.DatFiles
|
||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||
{
|
||||
// Get the possibly unsorted list
|
||||
ConcurrentList<DatItem> sortedlist = this[key];
|
||||
ConcurrentList<DatItem>? sortedlist = this[key];
|
||||
|
||||
// Sort the list of items to be consistent
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
if (sortedlist != null)
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1084,7 +1087,7 @@ namespace SabreTools.DatFiles
|
||||
items.TryRemove(key, out _);
|
||||
|
||||
// If there are no non-blank items, remove
|
||||
else if (!items[key].Any(i => i != null && i.ItemType != ItemType.Blank))
|
||||
else if (!items[key]!.Any(i => i != null && i.ItemType != ItemType.Blank))
|
||||
items.TryRemove(key, out _);
|
||||
}
|
||||
}
|
||||
@@ -1097,8 +1100,8 @@ namespace SabreTools.DatFiles
|
||||
var keys = items.Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
ConcurrentList<DatItem> oldItemList = items[key];
|
||||
ConcurrentList<DatItem> newItemList = oldItemList.Where(i => !i.Remove).ToConcurrentList();
|
||||
ConcurrentList<DatItem>? oldItemList = items[key];
|
||||
ConcurrentList<DatItem>? newItemList = oldItemList?.Where(i => !i.Remove)?.ToConcurrentList();
|
||||
|
||||
Remove(key);
|
||||
AddRange(key, newItemList);
|
||||
@@ -1127,7 +1130,10 @@ namespace SabreTools.DatFiles
|
||||
return output;
|
||||
|
||||
// Try to find duplicates
|
||||
ConcurrentList<DatItem> roms = this[key];
|
||||
ConcurrentList<DatItem>? roms = this[key];
|
||||
if (roms == null)
|
||||
return output;
|
||||
|
||||
ConcurrentList<DatItem> left = new();
|
||||
for (int i = 0; i < roms.Count; i++)
|
||||
{
|
||||
@@ -1174,8 +1180,8 @@ namespace SabreTools.DatFiles
|
||||
return false;
|
||||
|
||||
// Try to find duplicates
|
||||
ConcurrentList<DatItem> roms = this[key];
|
||||
return roms.Any(r => datItem.Equals(r));
|
||||
ConcurrentList<DatItem>? roms = this[key];
|
||||
return roms?.Any(r => datItem.Equals(r)) == true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1193,7 +1199,10 @@ namespace SabreTools.DatFiles
|
||||
// Loop through and add
|
||||
foreach (string key in items.Keys)
|
||||
{
|
||||
ConcurrentList<DatItem> datItems = items[key];
|
||||
ConcurrentList<DatItem>? datItems = items[key];
|
||||
if (datItems == null)
|
||||
continue;
|
||||
|
||||
foreach (DatItem item in datItems)
|
||||
{
|
||||
AddItemStatistics(item);
|
||||
@@ -1286,45 +1295,45 @@ namespace SabreTools.DatFiles
|
||||
|
||||
#region IDictionary Implementations
|
||||
|
||||
public ICollection<ConcurrentList<DatItem>> Values => ((IDictionary<string, ConcurrentList<DatItem>>)items).Values;
|
||||
public ICollection<ConcurrentList<DatItem>?> Values => ((IDictionary<string, ConcurrentList<DatItem>?>)items).Values;
|
||||
|
||||
public int Count => ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).Count;
|
||||
public int Count => ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).Count;
|
||||
|
||||
public bool IsReadOnly => ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).IsReadOnly;
|
||||
public bool IsReadOnly => ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).IsReadOnly;
|
||||
|
||||
public bool TryGetValue(string key, out ConcurrentList<DatItem> value)
|
||||
public bool TryGetValue(string key, out ConcurrentList<DatItem>? value)
|
||||
{
|
||||
return ((IDictionary<string, ConcurrentList<DatItem>>)items).TryGetValue(key, out value);
|
||||
return ((IDictionary<string, ConcurrentList<DatItem>?>)items).TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<string, ConcurrentList<DatItem>> item)
|
||||
public void Add(KeyValuePair<string, ConcurrentList<DatItem>?> item)
|
||||
{
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).Add(item);
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).Clear();
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).Clear();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<string, ConcurrentList<DatItem>> item)
|
||||
public bool Contains(KeyValuePair<string, ConcurrentList<DatItem>?> item)
|
||||
{
|
||||
return ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).Contains(item);
|
||||
return ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<string, ConcurrentList<DatItem>>[] array, int arrayIndex)
|
||||
public void CopyTo(KeyValuePair<string, ConcurrentList<DatItem>?>[] array, int arrayIndex)
|
||||
{
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).CopyTo(array, arrayIndex);
|
||||
((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<string, ConcurrentList<DatItem>> item)
|
||||
public bool Remove(KeyValuePair<string, ConcurrentList<DatItem>?> item)
|
||||
{
|
||||
return ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>>>)items).Remove(item);
|
||||
return ((ICollection<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).Remove(item);
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, ConcurrentList<DatItem>>> GetEnumerator()
|
||||
public IEnumerator<KeyValuePair<string, ConcurrentList<DatItem>?>> GetEnumerator()
|
||||
{
|
||||
return ((IEnumerable<KeyValuePair<string, ConcurrentList<DatItem>>>)items).GetEnumerator();
|
||||
return ((IEnumerable<KeyValuePair<string, ConcurrentList<DatItem>?>>)items).GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace SabreTools.DatFiles
|
||||
/// Item dictionary with statistics, bucketing, and sorting
|
||||
/// </summary>
|
||||
[JsonObject("items"), XmlRoot("items")]
|
||||
public class ItemDictionaryDB : IDictionary<string, ConcurrentList<DatItem>>
|
||||
public class ItemDictionaryDB : IDictionary<string, ConcurrentList<DatItem>?>
|
||||
{
|
||||
#region Private instance variables
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Internal database connection for the class
|
||||
/// </summary>
|
||||
private readonly SqliteConnection dbc = null;
|
||||
private readonly SqliteConnection? dbc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Internal item dictionary name
|
||||
/// </summary>
|
||||
private string itemDictionaryFileName = null;
|
||||
private string? itemDictionaryFileName = null;
|
||||
|
||||
/// <summary>
|
||||
/// Lock for statistics calculation
|
||||
@@ -94,7 +94,7 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
// If we have no database connection, we can't do anything
|
||||
if (dbc == null)
|
||||
return null;
|
||||
return Array.Empty<string>();
|
||||
|
||||
// Open the database connection
|
||||
dbc.Open();
|
||||
@@ -131,10 +131,13 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <returns>List of the keys in sorted order</returns>
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public List<string> SortedKeys
|
||||
public List<string>? SortedKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Keys == null)
|
||||
return null;
|
||||
|
||||
var keys = Keys.ToList();
|
||||
keys.Sort(new NaturalComparer());
|
||||
return keys;
|
||||
@@ -444,7 +447,7 @@ namespace SabreTools.DatFiles
|
||||
/// Passthrough to access the file dictionary
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to reference</param>
|
||||
public ConcurrentList<DatItem> this[string key]
|
||||
public ConcurrentList<DatItem>? this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -471,8 +474,9 @@ namespace SabreTools.DatFiles
|
||||
while (sldr.Read())
|
||||
{
|
||||
string itemString = sldr.GetString(0);
|
||||
DatItem datItem = JsonConvert.DeserializeObject<DatItem>(itemString);
|
||||
items.Add(datItem);
|
||||
DatItem? datItem = JsonConvert.DeserializeObject<DatItem>(itemString);
|
||||
if (datItem != null)
|
||||
items.Add(datItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,7 +562,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to add to</param>
|
||||
/// <param name="value">Value to add to the dictionary</param>
|
||||
public void Add(string key, ConcurrentList<DatItem> value)
|
||||
public void Add(string key, ConcurrentList<DatItem>? value)
|
||||
{
|
||||
AddRange(key, value);
|
||||
}
|
||||
@@ -579,135 +583,135 @@ namespace SabreTools.DatFiles
|
||||
RemovedCount++;
|
||||
|
||||
// Now we do different things for each item type
|
||||
switch (item.ItemType)
|
||||
switch (item)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
case Adjuster:
|
||||
AdjusterCount++;
|
||||
break;
|
||||
case ItemType.Analog:
|
||||
case Analog:
|
||||
AnalogCount++;
|
||||
break;
|
||||
case ItemType.Archive:
|
||||
case Archive:
|
||||
ArchiveCount++;
|
||||
break;
|
||||
case ItemType.BiosSet:
|
||||
case BiosSet:
|
||||
BiosSetCount++;
|
||||
break;
|
||||
case ItemType.Chip:
|
||||
case Chip:
|
||||
ChipCount++;
|
||||
break;
|
||||
case ItemType.Condition:
|
||||
case Condition:
|
||||
ConditionCount++;
|
||||
break;
|
||||
case ItemType.Configuration:
|
||||
case Configuration:
|
||||
ConfigurationCount++;
|
||||
break;
|
||||
case ItemType.DataArea:
|
||||
case DataArea:
|
||||
DataAreaCount++;
|
||||
break;
|
||||
case ItemType.Device:
|
||||
case Device:
|
||||
DeviceCount++;
|
||||
break;
|
||||
case ItemType.DeviceReference:
|
||||
case DeviceReference:
|
||||
DeviceReferenceCount++;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
case DipSwitch:
|
||||
DipSwitchCount++;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
case Disk disk:
|
||||
DiskCount++;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.DiskArea:
|
||||
case DiskArea:
|
||||
DiskAreaCount++;
|
||||
break;
|
||||
case ItemType.Display:
|
||||
case Display:
|
||||
DisplayCount++;
|
||||
break;
|
||||
case ItemType.Driver:
|
||||
case Driver:
|
||||
DriverCount++;
|
||||
break;
|
||||
case ItemType.Feature:
|
||||
case Feature:
|
||||
FeatureCount++;
|
||||
break;
|
||||
case ItemType.Info:
|
||||
case Info:
|
||||
InfoCount++;
|
||||
break;
|
||||
case ItemType.Input:
|
||||
case Input:
|
||||
InputCount++;
|
||||
break;
|
||||
case ItemType.Media:
|
||||
case Media media:
|
||||
MediaCount++;
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace((item as Media).SpamSum) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Part:
|
||||
case Part:
|
||||
PartCount++;
|
||||
break;
|
||||
case ItemType.PartFeature:
|
||||
case PartFeature:
|
||||
PartFeatureCount++;
|
||||
break;
|
||||
case ItemType.Port:
|
||||
case Port:
|
||||
PortCount++;
|
||||
break;
|
||||
case ItemType.RamOption:
|
||||
case RamOption:
|
||||
RamOptionCount++;
|
||||
break;
|
||||
case ItemType.Release:
|
||||
case Release:
|
||||
ReleaseCount++;
|
||||
break;
|
||||
case ItemType.ReleaseDetails:
|
||||
case ReleaseDetails:
|
||||
ReleaseDetailsCount++;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
case Rom rom:
|
||||
RomCount++;
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += (item as Rom).Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace((item as Rom).SpamSum) ? 0 : 1);
|
||||
TotalSize += rom.Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
case Sample:
|
||||
SampleCount++;
|
||||
break;
|
||||
case ItemType.Serials:
|
||||
case Serials:
|
||||
SerialsCount++;
|
||||
break;
|
||||
case ItemType.SharedFeature:
|
||||
case SharedFeature:
|
||||
SharedFeatureCount++;
|
||||
break;
|
||||
case ItemType.Slot:
|
||||
case Slot:
|
||||
SlotCount++;
|
||||
break;
|
||||
case ItemType.SoftwareList:
|
||||
case SoftwareList:
|
||||
SoftwareListCount++;
|
||||
break;
|
||||
case ItemType.Sound:
|
||||
case Sound:
|
||||
SoundCount++;
|
||||
break;
|
||||
case ItemType.SourceDetails:
|
||||
case SourceDetails:
|
||||
SourceDetailsCount++;
|
||||
break;
|
||||
}
|
||||
@@ -719,7 +723,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="key">Key in the dictionary to add to</param>
|
||||
/// <param name="value">Value to add to the dictionary</param>
|
||||
public void AddRange(string key, ConcurrentList<DatItem> value)
|
||||
public void AddRange(string key, ConcurrentList<DatItem>? value)
|
||||
{
|
||||
// Explicit lock for some weird corner cases
|
||||
lock (key)
|
||||
@@ -797,7 +801,7 @@ namespace SabreTools.DatFiles
|
||||
// Explicit lock for some weird corner cases
|
||||
lock (key)
|
||||
{
|
||||
return Keys.Contains(key);
|
||||
return Keys?.Contains(key) == true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,10 +820,10 @@ namespace SabreTools.DatFiles
|
||||
// Explicit lock for some weird corner cases
|
||||
lock (key)
|
||||
{
|
||||
if (!Keys.Contains(key))
|
||||
if (Keys?.Contains(key) != true)
|
||||
return false;
|
||||
|
||||
return this[key].Contains(value);
|
||||
return this[key]?.Contains(value) == true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,7 +834,7 @@ namespace SabreTools.DatFiles
|
||||
public void EnsureKey(string key)
|
||||
{
|
||||
// If the key is missing from the dictionary, add it
|
||||
if (Keys.Contains(key))
|
||||
if (Keys?.Contains(key) == true)
|
||||
return;
|
||||
|
||||
// If we have no database connection, we can't do anything
|
||||
@@ -858,7 +862,7 @@ namespace SabreTools.DatFiles
|
||||
lock (key)
|
||||
{
|
||||
// Get the list, if possible
|
||||
ConcurrentList<DatItem> fi = this[key];
|
||||
ConcurrentList<DatItem>? fi = this[key];
|
||||
if (fi == null)
|
||||
return new ConcurrentList<DatItem>();
|
||||
|
||||
@@ -880,11 +884,11 @@ namespace SabreTools.DatFiles
|
||||
lock (key)
|
||||
{
|
||||
// If the key doesn't exist, return
|
||||
if (!ContainsKey(key))
|
||||
if (!ContainsKey(key) || this[key] == null)
|
||||
return false;
|
||||
|
||||
// Remove the statistics first
|
||||
foreach (DatItem item in this[key])
|
||||
foreach (DatItem item in this[key]!)
|
||||
{
|
||||
RemoveItemStatistics(item);
|
||||
}
|
||||
@@ -939,11 +943,11 @@ namespace SabreTools.DatFiles
|
||||
public bool Reset(string key)
|
||||
{
|
||||
// If the key doesn't exist, return
|
||||
if (!ContainsKey(key))
|
||||
if (!ContainsKey(key) || this[key] == null)
|
||||
return false;
|
||||
|
||||
// Remove the statistics first
|
||||
foreach (DatItem item in this[key])
|
||||
foreach (DatItem item in this[key]!)
|
||||
{
|
||||
RemoveItemStatistics(item);
|
||||
}
|
||||
@@ -966,7 +970,7 @@ namespace SabreTools.DatFiles
|
||||
/// Remove from the statistics given a DatItem
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove info for</param>
|
||||
public void RemoveItemStatistics(DatItem item)
|
||||
public void RemoveItemStatistics(DatItem? item)
|
||||
{
|
||||
// If we have a null item, we can't do anything
|
||||
if (item == null)
|
||||
@@ -982,124 +986,124 @@ namespace SabreTools.DatFiles
|
||||
RemovedCount--;
|
||||
|
||||
// Now we do different things for each item type
|
||||
switch (item.ItemType)
|
||||
switch (item)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
case Adjuster:
|
||||
AdjusterCount--;
|
||||
break;
|
||||
case ItemType.Analog:
|
||||
case Analog:
|
||||
AnalogCount--;
|
||||
break;
|
||||
case ItemType.Archive:
|
||||
case Archive:
|
||||
ArchiveCount--;
|
||||
break;
|
||||
case ItemType.BiosSet:
|
||||
case BiosSet:
|
||||
BiosSetCount--;
|
||||
break;
|
||||
case ItemType.Chip:
|
||||
case Chip:
|
||||
ChipCount--;
|
||||
break;
|
||||
case ItemType.Condition:
|
||||
case Condition:
|
||||
ConditionCount--;
|
||||
break;
|
||||
case ItemType.Configuration:
|
||||
case Configuration:
|
||||
ConfigurationCount--;
|
||||
break;
|
||||
case ItemType.DataArea:
|
||||
case DataArea:
|
||||
DataAreaCount--;
|
||||
break;
|
||||
case ItemType.Device:
|
||||
case Device:
|
||||
DeviceCount--;
|
||||
break;
|
||||
case ItemType.DeviceReference:
|
||||
case DeviceReference:
|
||||
DeviceReferenceCount--;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
case DipSwitch:
|
||||
DipSwitchCount--;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
case Disk disk:
|
||||
DiskCount--;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (disk.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.DiskArea:
|
||||
case DiskArea:
|
||||
DiskAreaCount--;
|
||||
break;
|
||||
case ItemType.Display:
|
||||
case Display:
|
||||
DisplayCount--;
|
||||
break;
|
||||
case ItemType.Driver:
|
||||
case Driver:
|
||||
DriverCount--;
|
||||
break;
|
||||
case ItemType.Feature:
|
||||
case Feature:
|
||||
FeatureCount--;
|
||||
break;
|
||||
case ItemType.Info:
|
||||
case Info:
|
||||
InfoCount--;
|
||||
break;
|
||||
case ItemType.Input:
|
||||
case Input:
|
||||
InputCount--;
|
||||
break;
|
||||
case ItemType.Media:
|
||||
case Media media:
|
||||
MediaCount--;
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Part:
|
||||
case Part:
|
||||
PartCount--;
|
||||
break;
|
||||
case ItemType.PartFeature:
|
||||
case PartFeature:
|
||||
PartFeatureCount--;
|
||||
break;
|
||||
case ItemType.Port:
|
||||
case Port:
|
||||
PortCount--;
|
||||
break;
|
||||
case ItemType.RamOption:
|
||||
case RamOption:
|
||||
RamOptionCount--;
|
||||
break;
|
||||
case ItemType.Release:
|
||||
case Release:
|
||||
ReleaseCount--;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
case Rom rom:
|
||||
RomCount--;
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= (item as Rom).Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
TotalSize -= rom.Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (rom.ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
case Sample:
|
||||
SampleCount--;
|
||||
break;
|
||||
case ItemType.SharedFeature:
|
||||
case SharedFeature:
|
||||
SharedFeatureCount--;
|
||||
break;
|
||||
case ItemType.Slot:
|
||||
case Slot:
|
||||
SlotCount--;
|
||||
break;
|
||||
case ItemType.SoftwareList:
|
||||
case SoftwareList:
|
||||
SoftwareListCount--;
|
||||
break;
|
||||
case ItemType.Sound:
|
||||
case Sound:
|
||||
SoundCount--;
|
||||
break;
|
||||
}
|
||||
@@ -1196,11 +1200,13 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k =>
|
||||
{
|
||||
string key = oldkeys[k];
|
||||
if (this[key] == null)
|
||||
return;
|
||||
|
||||
// Now add each of the roms to their respective keys
|
||||
for (int i = 0; i < this[key].Count; i++)
|
||||
for (int i = 0; i < this[key]!.Count; i++)
|
||||
{
|
||||
DatItem item = this[key][i];
|
||||
DatItem item = this[key]![i];
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
@@ -1217,7 +1223,7 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
}
|
||||
|
||||
// If the key is now empty, remove it
|
||||
if (this[key].Count == 0)
|
||||
if (this[key]!.Count == 0)
|
||||
Remove(key);
|
||||
});
|
||||
}
|
||||
@@ -1255,10 +1261,11 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||
{
|
||||
// Get the possibly unsorted list
|
||||
ConcurrentList<DatItem> sortedlist = this[key];
|
||||
ConcurrentList<DatItem>? sortedlist = this[key];
|
||||
|
||||
// Sort the list of items to be consistent
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
if (sortedlist != null)
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1280,7 +1287,7 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
this[key] = null;
|
||||
|
||||
// If there are no non-blank items, remove
|
||||
else if (!this[key].Any(i => i != null && i.ItemType != ItemType.Blank))
|
||||
else if (!this[key]!.Any(i => i != null && i.ItemType != ItemType.Blank))
|
||||
this[key] = null;
|
||||
}
|
||||
}
|
||||
@@ -1290,11 +1297,14 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
/// </summary>
|
||||
public void ClearMarked()
|
||||
{
|
||||
if (Keys == null)
|
||||
return;
|
||||
|
||||
var keys = Keys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
ConcurrentList<DatItem> oldItemList = this[key];
|
||||
ConcurrentList<DatItem> newItemList = oldItemList.Where(i => !i.Remove).ToConcurrentList();
|
||||
ConcurrentList<DatItem>? oldItemList = this[key];
|
||||
ConcurrentList<DatItem>? newItemList = oldItemList?.Where(i => !i.Remove)?.ToConcurrentList();
|
||||
|
||||
Remove(key);
|
||||
AddRange(key, newItemList);
|
||||
@@ -1319,11 +1329,11 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
string key = SortAndGetKey(datItem, sorted);
|
||||
|
||||
// If the key doesn't exist, return the empty list
|
||||
if (!ContainsKey(key))
|
||||
if (!ContainsKey(key) || this[key] == null)
|
||||
return output;
|
||||
|
||||
// Try to find duplicates
|
||||
ConcurrentList<DatItem> roms = this[key];
|
||||
ConcurrentList<DatItem> roms = this[key]!;
|
||||
ConcurrentList<DatItem> left = new();
|
||||
for (int i = 0; i < roms.Count; i++)
|
||||
{
|
||||
@@ -1370,8 +1380,8 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
return false;
|
||||
|
||||
// Try to find duplicates
|
||||
ConcurrentList<DatItem> roms = this[key];
|
||||
return roms.Any(r => datItem.Equals(r));
|
||||
ConcurrentList<DatItem>? roms = this[key];
|
||||
return roms?.Any(r => datItem.Equals(r)) == true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1383,13 +1393,16 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
ResetStatistics();
|
||||
|
||||
// If we have a blank Dat in any way, return
|
||||
if (dbc == null)
|
||||
if (dbc == null || Keys == null)
|
||||
return;
|
||||
|
||||
// Loop through and add
|
||||
foreach (string key in Keys)
|
||||
{
|
||||
ConcurrentList<DatItem> datItems = this[key];
|
||||
ConcurrentList<DatItem>? datItems = this[key];
|
||||
if (datItems == null)
|
||||
continue;
|
||||
|
||||
foreach (DatItem item in datItems)
|
||||
{
|
||||
AddItemStatistics(item);
|
||||
@@ -1482,25 +1495,25 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
|
||||
#region IDictionary Implementations
|
||||
|
||||
public ICollection<ConcurrentList<DatItem>> Values => throw new NotImplementedException();
|
||||
public ICollection<ConcurrentList<DatItem>?> Values => throw new NotImplementedException();
|
||||
|
||||
public int Count => throw new NotImplementedException();
|
||||
|
||||
public bool IsReadOnly => throw new NotImplementedException();
|
||||
|
||||
public bool TryGetValue(string key, out ConcurrentList<DatItem> value) => throw new NotImplementedException();
|
||||
public bool TryGetValue(string key, out ConcurrentList<DatItem>? value) => throw new NotImplementedException();
|
||||
|
||||
public void Add(KeyValuePair<string, ConcurrentList<DatItem>> item) => throw new NotImplementedException();
|
||||
public void Add(KeyValuePair<string, ConcurrentList<DatItem>?> item) => throw new NotImplementedException();
|
||||
|
||||
public void Clear() => throw new NotImplementedException();
|
||||
|
||||
public bool Contains(KeyValuePair<string, ConcurrentList<DatItem>> item) => throw new NotImplementedException();
|
||||
public bool Contains(KeyValuePair<string, ConcurrentList<DatItem>?> item) => throw new NotImplementedException();
|
||||
|
||||
public void CopyTo(KeyValuePair<string, ConcurrentList<DatItem>>[] array, int arrayIndex) => throw new NotImplementedException();
|
||||
public void CopyTo(KeyValuePair<string, ConcurrentList<DatItem>?>[] array, int arrayIndex) => throw new NotImplementedException();
|
||||
|
||||
public bool Remove(KeyValuePair<string, ConcurrentList<DatItem>> item) => throw new NotImplementedException();
|
||||
public bool Remove(KeyValuePair<string, ConcurrentList<DatItem>?> item) => throw new NotImplementedException();
|
||||
|
||||
public IEnumerator<KeyValuePair<string, ConcurrentList<DatItem>>> GetEnumerator() => throw new NotImplementedException();
|
||||
public IEnumerator<KeyValuePair<string, ConcurrentList<DatItem>?>> GetEnumerator() => throw new NotImplementedException();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,17 +18,17 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Mappings to set DatHeader fields
|
||||
/// </summary>
|
||||
public Dictionary<DatHeaderField, string> DatHeaderMappings { get; set; }
|
||||
public Dictionary<DatHeaderField, string>? DatHeaderMappings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mappings to set Machine fields
|
||||
/// </summary>
|
||||
public Dictionary<MachineField, string> MachineMappings { get; set; }
|
||||
public Dictionary<MachineField, string>? MachineMappings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mappings to set DatItem fields
|
||||
/// </summary>
|
||||
public Dictionary<DatItemField, string> DatItemMappings { get; set; }
|
||||
public Dictionary<DatItemField, string>? DatItemMappings { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="datHeader">DatHeader to set fields on</param>
|
||||
public void SetFields(DatHeader datHeader)
|
||||
{
|
||||
if (datHeader == null)
|
||||
if (datHeader == null || DatHeaderMappings == null)
|
||||
return;
|
||||
|
||||
if (DatHeaderMappings.ContainsKey(DatHeaderField.Author))
|
||||
@@ -213,49 +213,51 @@ namespace SabreTools.DatFiles
|
||||
if (datItem == null || DatItemMappings == null)
|
||||
return;
|
||||
|
||||
#region Common
|
||||
#region Common
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Name))
|
||||
datItem.SetName(DatItemMappings[DatItemField.Name]);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Item-Specific
|
||||
|
||||
if (datItem is Adjuster) SetFields(datItem as Adjuster);
|
||||
else if (datItem is Analog) SetFields(datItem as Analog);
|
||||
else if (datItem is Archive) SetFields(datItem as Archive);
|
||||
else if (datItem is BiosSet) SetFields(datItem as BiosSet);
|
||||
else if (datItem is Chip) SetFields(datItem as Chip);
|
||||
else if (datItem is Condition) SetFields(datItem as Condition);
|
||||
else if (datItem is Configuration) SetFields(datItem as Configuration);
|
||||
else if (datItem is Control) SetFields(datItem as Control);
|
||||
else if (datItem is DataArea) SetFields(datItem as DataArea);
|
||||
else if (datItem is Device) SetFields(datItem as Device);
|
||||
else if (datItem is DipSwitch) SetFields(datItem as DipSwitch);
|
||||
else if (datItem is Disk) SetFields(datItem as Disk);
|
||||
else if (datItem is DiskArea) SetFields(datItem as DiskArea);
|
||||
else if (datItem is Display) SetFields(datItem as Display);
|
||||
else if (datItem is Driver) SetFields(datItem as Driver);
|
||||
else if (datItem is Extension) SetFields(datItem as Extension);
|
||||
else if (datItem is Feature) SetFields(datItem as Feature);
|
||||
else if (datItem is Info) SetFields(datItem as Info);
|
||||
else if (datItem is Input) SetFields(datItem as Input);
|
||||
else if (datItem is Instance) SetFields(datItem as Instance);
|
||||
else if (datItem is Location) SetFields(datItem as Location);
|
||||
else if (datItem is Media) SetFields(datItem as Media);
|
||||
else if (datItem is Part) SetFields(datItem as Part);
|
||||
else if (datItem is PartFeature) SetFields(datItem as PartFeature);
|
||||
else if (datItem is Port) SetFields(datItem as Port);
|
||||
else if (datItem is RamOption) SetFields(datItem as RamOption);
|
||||
else if (datItem is Release) SetFields(datItem as Release);
|
||||
else if (datItem is Rom) SetFields(datItem as Rom);
|
||||
else if (datItem is Setting) SetFields(datItem as Setting);
|
||||
else if (datItem is SharedFeature) SetFields(datItem as SharedFeature);
|
||||
else if (datItem is Slot) SetFields(datItem as Slot);
|
||||
else if (datItem is SlotOption) SetFields(datItem as SlotOption);
|
||||
else if (datItem is SoftwareList) SetFields(datItem as SoftwareList);
|
||||
else if (datItem is Sound) SetFields(datItem as Sound);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Adjuster adjuster: SetFields(adjuster); break;
|
||||
case Analog analog: SetFields(analog); break;
|
||||
case Archive archive: SetFields(archive); break;
|
||||
case BiosSet biosSet: SetFields(biosSet); break;
|
||||
case Chip chip: SetFields(chip); break;
|
||||
case Condition condition: SetFields(condition); break;
|
||||
case Configuration condition: SetFields(condition); break;
|
||||
case Control control: SetFields(control); break;
|
||||
case DataArea dataArea: SetFields(dataArea); break;
|
||||
case Device device: SetFields(device); break;
|
||||
case DipSwitch dipSwitch: SetFields(dipSwitch); break;
|
||||
case Disk disk: SetFields(disk); break;
|
||||
case DiskArea diskArea: SetFields(diskArea); break;
|
||||
case Display display: SetFields(display); break;
|
||||
case Driver driver: SetFields(driver); break;
|
||||
case Extension extension: SetFields(extension); break;
|
||||
case Feature feature: SetFields(feature); break;
|
||||
case Input input: SetFields(input); break;
|
||||
case Instance instance: SetFields(instance); break;
|
||||
case Location location: SetFields(location); break;
|
||||
case Media media: SetFields(media); break;
|
||||
case Part part: SetFields(part); break;
|
||||
case PartFeature partFeature: SetFields(partFeature); break;
|
||||
case Port port: SetFields(port); break;
|
||||
case RamOption ramOption: SetFields(ramOption); break;
|
||||
case Release release: SetFields(release); break;
|
||||
case Rom rom: SetFields(rom); break;
|
||||
case Setting setting: SetFields(setting); break;
|
||||
case SharedFeature sharedFeat: SetFields(sharedFeat); break;
|
||||
case Slot slot: SetFields(slot); break;
|
||||
case SlotOption slotOption: SetFields(slotOption); break;
|
||||
case SoftwareList softwareList: SetFields(softwareList); break;
|
||||
case Sound sound: SetFields(sound); break;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -390,7 +392,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="adjuster">Adjuster to remove replace fields in</param>
|
||||
private void SetFields(Adjuster adjuster)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Default))
|
||||
adjuster.Default = DatItemMappings[DatItemField.Default].AsYesNo();
|
||||
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
@@ -409,7 +411,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="analog">Analog to remove replace fields in</param>
|
||||
private void SetFields(Analog analog)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Analog_Mask))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Analog_Mask))
|
||||
analog.Mask = DatItemMappings[DatItemField.Analog_Mask];
|
||||
}
|
||||
|
||||
@@ -419,31 +421,31 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="archive">Archive to remove replace fields in</param>
|
||||
private void SetFields(Archive archive)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Categories))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Categories))
|
||||
archive.Categories = DatItemMappings[DatItemField.Categories];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Clone))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Clone))
|
||||
archive.CloneValue = DatItemMappings[DatItemField.Clone];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Complete))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Complete))
|
||||
archive.Complete = DatItemMappings[DatItemField.Complete];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.DevStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.DevStatus))
|
||||
archive.DevStatus = DatItemMappings[DatItemField.DevStatus];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Languages))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Languages))
|
||||
archive.Languages = DatItemMappings[DatItemField.Languages];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Number))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Number))
|
||||
archive.Number = DatItemMappings[DatItemField.Number];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Physical))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Physical))
|
||||
archive.Physical = DatItemMappings[DatItemField.Physical];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Region))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Region))
|
||||
archive.Region = DatItemMappings[DatItemField.Region];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.RegParent))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.RegParent))
|
||||
archive.RegParent = DatItemMappings[DatItemField.RegParent];
|
||||
}
|
||||
|
||||
@@ -453,10 +455,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="biosSet">BiosSet to remove replace fields in</param>
|
||||
private void SetFields(BiosSet biosSet)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Default))
|
||||
biosSet.Default = DatItemMappings[DatItemField.Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Description))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Description))
|
||||
biosSet.Description = DatItemMappings[DatItemField.Description];
|
||||
}
|
||||
|
||||
@@ -466,13 +468,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="chip">Chip to remove replace fields in</param>
|
||||
private void SetFields(Chip chip)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.ChipType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.ChipType))
|
||||
chip.ChipType = DatItemMappings[DatItemField.ChipType].AsChipType();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Clock))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Clock))
|
||||
chip.Clock = Utilities.CleanLong(DatItemMappings[DatItemField.Clock]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
chip.Tag = DatItemMappings[DatItemField.Tag];
|
||||
}
|
||||
|
||||
@@ -485,30 +487,30 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
if (sub)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Condition_Mask))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Condition_Mask))
|
||||
condition.Mask = DatItemMappings[DatItemField.Condition_Mask];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Condition_Relation))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Condition_Relation))
|
||||
condition.Relation = DatItemMappings[DatItemField.Condition_Relation].AsRelation();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Condition_Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Condition_Tag))
|
||||
condition.Tag = DatItemMappings[DatItemField.Condition_Tag];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Condition_Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Condition_Value))
|
||||
condition.Value = DatItemMappings[DatItemField.Condition_Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Mask))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Mask))
|
||||
condition.Mask = DatItemMappings[DatItemField.Mask];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Relation))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Relation))
|
||||
condition.Relation = DatItemMappings[DatItemField.Relation].AsRelation();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
condition.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Value))
|
||||
condition.Value = DatItemMappings[DatItemField.Value];
|
||||
}
|
||||
}
|
||||
@@ -519,10 +521,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="configuration">Configuration to remove replace fields in</param>
|
||||
private void SetFields(Configuration configuration)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Mask))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Mask))
|
||||
configuration.Mask = DatItemMappings[DatItemField.Mask];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
configuration.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (configuration.ConditionsSpecified)
|
||||
@@ -556,40 +558,40 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="control">Control to remove replace fields in</param>
|
||||
private void SetFields(Control control)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Buttons))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Buttons))
|
||||
control.Buttons = Utilities.CleanLong(DatItemMappings[DatItemField.Control_Buttons]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Type))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Type))
|
||||
control.ControlType = DatItemMappings[DatItemField.Control_Type].AsControlType();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_KeyDelta))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_KeyDelta))
|
||||
control.KeyDelta = Utilities.CleanLong(DatItemMappings[DatItemField.Control_KeyDelta]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Maximum))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Maximum))
|
||||
control.Maximum = Utilities.CleanLong(DatItemMappings[DatItemField.Control_Maximum]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Minimum))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Minimum))
|
||||
control.Minimum = Utilities.CleanLong(DatItemMappings[DatItemField.Control_Minimum]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Player))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Player))
|
||||
control.Player = Utilities.CleanLong(DatItemMappings[DatItemField.Control_Player]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_RequiredButtons))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_RequiredButtons))
|
||||
control.RequiredButtons = Utilities.CleanLong(DatItemMappings[DatItemField.Control_RequiredButtons]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Reverse))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Reverse))
|
||||
control.Reverse = DatItemMappings[DatItemField.Control_Reverse].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Sensitivity))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Sensitivity))
|
||||
control.Sensitivity = Utilities.CleanLong(DatItemMappings[DatItemField.Control_Sensitivity]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Ways))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Ways))
|
||||
control.Ways = DatItemMappings[DatItemField.Control_Ways];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Ways2))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Ways2))
|
||||
control.Ways2 = DatItemMappings[DatItemField.Control_Ways2];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Control_Ways3))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Control_Ways3))
|
||||
control.Ways3 = DatItemMappings[DatItemField.Control_Ways3];
|
||||
}
|
||||
|
||||
@@ -599,16 +601,16 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="dataArea">DataArea to remove replace fields in</param>
|
||||
private void SetFields(DataArea dataArea)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AreaEndianness))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AreaEndianness))
|
||||
dataArea.Endianness = DatItemMappings[DatItemField.AreaEndianness].AsEndianness();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AreaName))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AreaName))
|
||||
dataArea.Name = DatItemMappings[DatItemField.AreaName];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AreaSize))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AreaSize))
|
||||
dataArea.Size = Utilities.CleanLong(DatItemMappings[DatItemField.AreaSize]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AreaWidth))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AreaWidth))
|
||||
dataArea.Width = Utilities.CleanLong(DatItemMappings[DatItemField.AreaWidth]);
|
||||
}
|
||||
|
||||
@@ -618,19 +620,19 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="device">Device to remove replace fields in</param>
|
||||
private void SetFields(Device device)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.DeviceType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.DeviceType))
|
||||
device.DeviceType = DatItemMappings[DatItemField.DeviceType].AsDeviceType();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.FixedImage))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.FixedImage))
|
||||
device.FixedImage = DatItemMappings[DatItemField.FixedImage];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Interface))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Interface))
|
||||
device.Interface = DatItemMappings[DatItemField.Interface];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Mandatory))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Mandatory))
|
||||
device.Mandatory = Utilities.CleanLong(DatItemMappings[DatItemField.Mandatory]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
device.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (device.ExtensionsSpecified)
|
||||
@@ -656,10 +658,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="dipSwitch">DipSwitch to remove replace fields in</param>
|
||||
private void SetFields(DipSwitch dipSwitch)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Mask))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Mask))
|
||||
dipSwitch.Mask = DatItemMappings[DatItemField.Mask];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
dipSwitch.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (dipSwitch.ConditionsSpecified)
|
||||
@@ -696,28 +698,28 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="disk">Disk to remove replace fields in</param>
|
||||
private void SetFields(Disk disk)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Index))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Index))
|
||||
disk.Index = DatItemMappings[DatItemField.Index];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.MD5))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.MD5))
|
||||
disk.MD5 = DatItemMappings[DatItemField.MD5];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Merge))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Merge))
|
||||
disk.MergeTag = DatItemMappings[DatItemField.Merge];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Optional))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Optional))
|
||||
disk.Optional = DatItemMappings[DatItemField.Optional].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Region))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Region))
|
||||
disk.Region = DatItemMappings[DatItemField.Region];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA1))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA1))
|
||||
disk.SHA1 = DatItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Status))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Status))
|
||||
disk.ItemStatus = DatItemMappings[DatItemField.Status].AsItemStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Writable))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Writable))
|
||||
disk.Writable = DatItemMappings[DatItemField.Writable].AsYesNo();
|
||||
|
||||
disk.DiskArea ??= new DiskArea();
|
||||
@@ -733,7 +735,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="diskArea">DiskArea to remove replace fields in</param>
|
||||
private void SetFields(DiskArea diskArea)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AreaName))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AreaName))
|
||||
diskArea.Name = DatItemMappings[DatItemField.AreaName];
|
||||
}
|
||||
|
||||
@@ -743,46 +745,46 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="display">Display to remove replace fields in</param>
|
||||
private void SetFields(Display display)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.DisplayType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.DisplayType))
|
||||
display.DisplayType = DatItemMappings[DatItemField.DisplayType].AsDisplayType();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.FlipX))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.FlipX))
|
||||
display.FlipX = DatItemMappings[DatItemField.FlipX].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Height))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Height))
|
||||
display.Height = Utilities.CleanLong(DatItemMappings[DatItemField.Height]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.HBEnd))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.HBEnd))
|
||||
display.HBEnd = Utilities.CleanLong(DatItemMappings[DatItemField.HBEnd]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.HBStart))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.HBStart))
|
||||
display.HBStart = Utilities.CleanLong(DatItemMappings[DatItemField.HBStart]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.HTotal))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.HTotal))
|
||||
display.HTotal = Utilities.CleanLong(DatItemMappings[DatItemField.HTotal]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.PixClock))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.PixClock))
|
||||
display.PixClock = Utilities.CleanLong(DatItemMappings[DatItemField.PixClock]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Refresh))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Refresh))
|
||||
display.Refresh = Utilities.CleanDouble(DatItemMappings[DatItemField.Refresh]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Rotate))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Rotate))
|
||||
display.Rotate = Utilities.CleanLong(DatItemMappings[DatItemField.Rotate]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
display.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.VBEnd))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.VBEnd))
|
||||
display.VBEnd = Utilities.CleanLong(DatItemMappings[DatItemField.VBEnd]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.VBStart))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.VBStart))
|
||||
display.VBStart = Utilities.CleanLong(DatItemMappings[DatItemField.VBStart]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.VTotal))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.VTotal))
|
||||
display.VTotal = Utilities.CleanLong(DatItemMappings[DatItemField.VTotal]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Width))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Width))
|
||||
display.Width = Utilities.CleanLong(DatItemMappings[DatItemField.Width]);
|
||||
}
|
||||
|
||||
@@ -792,28 +794,28 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="driver">Driver to remove replace fields in</param>
|
||||
private void SetFields(Driver driver)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.CocktailStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.CocktailStatus))
|
||||
driver.Cocktail = DatItemMappings[DatItemField.CocktailStatus].AsSupportStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Incomplete))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Incomplete))
|
||||
driver.Incomplete = DatItemMappings[DatItemField.Incomplete].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.EmulationStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.EmulationStatus))
|
||||
driver.Emulation = DatItemMappings[DatItemField.EmulationStatus].AsSupportStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.NoSoundHardware))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.NoSoundHardware))
|
||||
driver.NoSoundHardware = DatItemMappings[DatItemField.NoSoundHardware].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.RequiresArtwork))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.RequiresArtwork))
|
||||
driver.RequiresArtwork = DatItemMappings[DatItemField.RequiresArtwork].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SaveStateStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SaveStateStatus))
|
||||
driver.SaveState = DatItemMappings[DatItemField.SaveStateStatus].AsSupported();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SupportStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SupportStatus))
|
||||
driver.Status = DatItemMappings[DatItemField.SupportStatus].AsSupportStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Unofficial))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Unofficial))
|
||||
driver.Unofficial = DatItemMappings[DatItemField.Unofficial].AsYesNo();
|
||||
}
|
||||
|
||||
@@ -823,7 +825,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="extension">Extension to remove replace fields in</param>
|
||||
private void SetFields(Extension extension)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Extension_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Extension_Name))
|
||||
extension.Name = DatItemMappings[DatItemField.Extension_Name];
|
||||
}
|
||||
|
||||
@@ -833,13 +835,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="feature">Feature to remove replace fields in</param>
|
||||
private void SetFields(Feature feature)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.FeatureOverall))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.FeatureOverall))
|
||||
feature.Overall = DatItemMappings[DatItemField.FeatureOverall].AsFeatureStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.FeatureStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.FeatureStatus))
|
||||
feature.Status = DatItemMappings[DatItemField.FeatureStatus].AsFeatureStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.FeatureType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.FeatureType))
|
||||
feature.Type = DatItemMappings[DatItemField.FeatureType].AsFeatureType();
|
||||
}
|
||||
|
||||
@@ -849,7 +851,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="info">Info to remove replace fields in</param>
|
||||
private void SetFields(Info info)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Value))
|
||||
info.Value = DatItemMappings[DatItemField.Value];
|
||||
}
|
||||
|
||||
@@ -859,16 +861,16 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="input">Input to remove replace fields in</param>
|
||||
private void SetFields(Input input)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Coins))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Coins))
|
||||
input.Coins = Utilities.CleanLong(DatItemMappings[DatItemField.Coins]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Players))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Players))
|
||||
input.Players = Utilities.CleanLong(DatItemMappings[DatItemField.Players]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Service))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Service))
|
||||
input.Service = DatItemMappings[DatItemField.Service].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tilt))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tilt))
|
||||
input.Tilt = DatItemMappings[DatItemField.Tilt].AsYesNo();
|
||||
|
||||
if (input.ControlsSpecified)
|
||||
@@ -886,10 +888,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="instance">Instance to remove replace fields in</param>
|
||||
private void SetFields(Instance instance)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Instance_BriefName))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Instance_BriefName))
|
||||
instance.BriefName = DatItemMappings[DatItemField.Instance_BriefName];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Instance_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Instance_Name))
|
||||
instance.BriefName = DatItemMappings[DatItemField.Instance_Name];
|
||||
}
|
||||
|
||||
@@ -899,13 +901,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="location">Location to remove replace fields in</param>
|
||||
private void SetFields(Location location)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Location_Inverted))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Inverted))
|
||||
location.Inverted = DatItemMappings[DatItemField.Location_Inverted].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Location_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Name))
|
||||
location.Name = DatItemMappings[DatItemField.Location_Name];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Location_Number))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Location_Number))
|
||||
location.Number = Utilities.CleanLong(DatItemMappings[DatItemField.Location_Number]);
|
||||
}
|
||||
|
||||
@@ -915,16 +917,16 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="media">Media to remove replace fields in</param>
|
||||
private void SetFields(Media media)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.MD5))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.MD5))
|
||||
media.MD5 = DatItemMappings[DatItemField.MD5];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA1))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA1))
|
||||
media.SHA1 = DatItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA256))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA256))
|
||||
media.SHA256 = DatItemMappings[DatItemField.SHA256];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SpamSum))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SpamSum))
|
||||
media.SpamSum = DatItemMappings[DatItemField.SpamSum];
|
||||
}
|
||||
|
||||
@@ -934,10 +936,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="part">Part to remove replace fields in</param>
|
||||
private void SetFields(Part part)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Part_Interface))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Part_Interface))
|
||||
part.Interface = DatItemMappings[DatItemField.Part_Interface];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Part_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Part_Name))
|
||||
part.Name = DatItemMappings[DatItemField.Part_Name];
|
||||
|
||||
if (part.FeaturesSpecified)
|
||||
@@ -955,10 +957,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="partFeature">PartFeature to remove replace fields in</param>
|
||||
private void SetFields(PartFeature partFeature)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Part_Feature_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Part_Feature_Name))
|
||||
partFeature.Name = DatItemMappings[DatItemField.Part_Feature_Name];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Part_Feature_Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Part_Feature_Value))
|
||||
partFeature.Value = DatItemMappings[DatItemField.Part_Feature_Value];
|
||||
}
|
||||
|
||||
@@ -968,7 +970,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="port">Port to remove replace fields in</param>
|
||||
private void SetFields(Port port)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
port.Tag = DatItemMappings[DatItemField.Tag];
|
||||
|
||||
if (port.AnalogsSpecified)
|
||||
@@ -986,10 +988,10 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="ramOption">RamOption to remove replace fields in</param>
|
||||
private void SetFields(RamOption ramOption)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Content))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Content))
|
||||
ramOption.Content = DatItemMappings[DatItemField.Content];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Default))
|
||||
ramOption.Default = DatItemMappings[DatItemField.Default].AsYesNo();
|
||||
}
|
||||
|
||||
@@ -999,16 +1001,16 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="release">Release to remove replace fields in</param>
|
||||
private void SetFields(Release release)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Date))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Date))
|
||||
release.Date = DatItemMappings[DatItemField.Date];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Default))
|
||||
release.Default = DatItemMappings[DatItemField.Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Language))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Language))
|
||||
release.Language = DatItemMappings[DatItemField.Language];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Region))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Region))
|
||||
release.Region = DatItemMappings[DatItemField.Region];
|
||||
}
|
||||
|
||||
@@ -1018,97 +1020,97 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="rom">Rom to remove replace fields in</param>
|
||||
private void SetFields(Rom rom)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AltName))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AltName))
|
||||
rom.AltName = DatItemMappings[DatItemField.AltName];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.AltTitle))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.AltTitle))
|
||||
rom.AltTitle = DatItemMappings[DatItemField.AltTitle];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.ArchiveDotOrgFormat))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.ArchiveDotOrgFormat))
|
||||
rom.ArchiveDotOrgFormat = DatItemMappings[DatItemField.ArchiveDotOrgFormat];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.ArchiveDotOrgSource))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.ArchiveDotOrgSource))
|
||||
rom.ArchiveDotOrgSource = DatItemMappings[DatItemField.ArchiveDotOrgSource];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Bios))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Bios))
|
||||
rom.Bios = DatItemMappings[DatItemField.Bios];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Boot))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Boot))
|
||||
rom.Boot = DatItemMappings[DatItemField.Boot];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.CRC))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.CRC))
|
||||
rom.CRC = DatItemMappings[DatItemField.CRC];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Date))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Date))
|
||||
rom.Date = DatItemMappings[DatItemField.Date];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Inverted))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Inverted))
|
||||
rom.Inverted = DatItemMappings[DatItemField.Inverted].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.LoadFlag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.LoadFlag))
|
||||
rom.LoadFlag = DatItemMappings[DatItemField.LoadFlag].AsLoadFlag();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.MD5))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.MD5))
|
||||
rom.MD5 = DatItemMappings[DatItemField.MD5];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Merge))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Merge))
|
||||
rom.MergeTag = DatItemMappings[DatItemField.Merge];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.MIA))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.MIA))
|
||||
rom.MIA = DatItemMappings[DatItemField.MIA].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Offset))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Offset))
|
||||
rom.Offset = DatItemMappings[DatItemField.Offset];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.OpenMSXSubType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.OpenMSXSubType))
|
||||
rom.OpenMSXSubType = DatItemMappings[DatItemField.OpenMSXSubType].AsOpenMSXSubType();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.OpenMSXType))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.OpenMSXType))
|
||||
rom.OpenMSXType = DatItemMappings[DatItemField.OpenMSXType];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Optional))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Optional))
|
||||
rom.Optional = DatItemMappings[DatItemField.Optional].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Original))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Original))
|
||||
rom.Original = new Original() { Content = DatItemMappings[DatItemField.Original] };
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.OriginalFilename))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.OriginalFilename))
|
||||
rom.OriginalFilename = DatItemMappings[DatItemField.OriginalFilename];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Region))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Region))
|
||||
rom.Region = DatItemMappings[DatItemField.Region];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Remark))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Remark))
|
||||
rom.Remark = DatItemMappings[DatItemField.Remark];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Rotation))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Rotation))
|
||||
rom.Rotation = DatItemMappings[DatItemField.Rotation];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA1))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA1))
|
||||
rom.SHA1 = DatItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA256))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA256))
|
||||
rom.SHA256 = DatItemMappings[DatItemField.SHA256];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA384))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA384))
|
||||
rom.SHA384 = DatItemMappings[DatItemField.SHA384];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SHA512))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SHA512))
|
||||
rom.SHA512 = DatItemMappings[DatItemField.SHA512];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Size))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Size))
|
||||
rom.Size = Utilities.CleanLong(DatItemMappings[DatItemField.Size]);
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SpamSum))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SpamSum))
|
||||
rom.SpamSum = DatItemMappings[DatItemField.SpamSum];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Status))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Status))
|
||||
rom.ItemStatus = DatItemMappings[DatItemField.Status].AsItemStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Summation))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Summation))
|
||||
rom.Summation = DatItemMappings[DatItemField.Summation];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Value))
|
||||
rom.Value = DatItemMappings[DatItemField.Value];
|
||||
|
||||
rom.DataArea ??= new DataArea();
|
||||
@@ -1124,13 +1126,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="setting">Setting to remove replace fields in</param>
|
||||
private void SetFields(Setting setting)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Setting_Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Default))
|
||||
setting.Default = DatItemMappings[DatItemField.Setting_Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Setting_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Name))
|
||||
setting.Name = DatItemMappings[DatItemField.Setting_Name];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Setting_Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Setting_Value))
|
||||
setting.Value = DatItemMappings[DatItemField.Setting_Value];
|
||||
|
||||
if (setting.ConditionsSpecified)
|
||||
@@ -1148,7 +1150,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="sharedFeature">SharedFeature to remove replace fields in</param>
|
||||
private void SetFields(SharedFeature sharedFeature)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Value))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Value))
|
||||
sharedFeature.Value = DatItemMappings[DatItemField.Value];
|
||||
}
|
||||
|
||||
@@ -1173,13 +1175,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="slotOption">SlotOption to remove replace fields in</param>
|
||||
private void SetFields(SlotOption slotOption)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SlotOption_Default))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SlotOption_Default))
|
||||
slotOption.Default = DatItemMappings[DatItemField.SlotOption_Default].AsYesNo();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SlotOption_DeviceName))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SlotOption_DeviceName))
|
||||
slotOption.DeviceName = DatItemMappings[DatItemField.SlotOption_DeviceName];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SlotOption_Name))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SlotOption_Name))
|
||||
slotOption.Name = DatItemMappings[DatItemField.SlotOption_Name];
|
||||
}
|
||||
|
||||
@@ -1189,13 +1191,13 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="softwareList">SoftwareList to remove replace fields in</param>
|
||||
private void SetFields(SoftwareList softwareList)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Filter))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Filter))
|
||||
softwareList.Filter = DatItemMappings[DatItemField.Filter];
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.SoftwareListStatus))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.SoftwareListStatus))
|
||||
softwareList.Status = DatItemMappings[DatItemField.SoftwareListStatus].AsSoftwareListStatus();
|
||||
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Tag))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Tag))
|
||||
softwareList.Tag = DatItemMappings[DatItemField.Tag];
|
||||
}
|
||||
|
||||
@@ -1205,7 +1207,7 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="sound">Sound to remove replace fields in</param>
|
||||
private void SetFields(Sound sound)
|
||||
{
|
||||
if (DatItemMappings.ContainsKey(DatItemField.Channels))
|
||||
if (DatItemMappings!.ContainsKey(DatItemField.Channels))
|
||||
sound.Channels = Utilities.CleanLong(DatItemMappings[DatItemField.Channels]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace SabreTools.DatItems
|
||||
#endregion // Metadata information
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Logging
|
||||
|
||||
/// <summary>
|
||||
@@ -242,6 +242,9 @@ namespace SabreTools.DatItems
|
||||
/// <param name="item">Existing item to copy information from</param>
|
||||
public void CopyMachineInformation(DatItem item)
|
||||
{
|
||||
if (item?.Machine == null)
|
||||
return;
|
||||
|
||||
Machine = (Machine)item.Machine.Clone();
|
||||
}
|
||||
|
||||
@@ -249,8 +252,11 @@ namespace SabreTools.DatItems
|
||||
/// Copy all machine information over in one shot
|
||||
/// </summary>
|
||||
/// <param name="machine">Existing machine to copy information from</param>
|
||||
public void CopyMachineInformation(Machine machine)
|
||||
public void CopyMachineInformation(Machine? machine)
|
||||
{
|
||||
if (machine == null)
|
||||
return;
|
||||
|
||||
Machine = (Machine)machine.Clone();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace SabreTools.Serialization
|
||||
|
||||
var metadataFile = new Models.Internal.MetadataFile
|
||||
{
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
if (item?.Row != null && item.Row.Any())
|
||||
@@ -115,7 +115,7 @@ namespace SabreTools.Serialization
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.EverdriveSMDB.MetadataFile"/> to <cref=Models.Internal."Header"/>
|
||||
/// </summary>
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel(MetadataFile item)
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel()
|
||||
{
|
||||
var header = new Models.Internal.Header
|
||||
{
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace SabreTools.Serialization
|
||||
|
||||
var metadataFile = new Models.Internal.MetadataFile
|
||||
{
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
var machine = ConvertMachineToInternalModel(item);
|
||||
@@ -277,7 +277,7 @@ namespace SabreTools.Serialization
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Hashfile.Hashfile"/> to <cref="Models.Internal.Header"/>
|
||||
/// </summary>
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel(Models.Hashfile.Hashfile item)
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel()
|
||||
{
|
||||
var header = new Models.Internal.Header
|
||||
{
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace SabreTools.Serialization
|
||||
|
||||
var metadataFile = new Models.Internal.MetadataFile
|
||||
{
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
[Models.Internal.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
if (item?.Set != null && item.Set.Any())
|
||||
@@ -209,7 +209,7 @@ namespace SabreTools.Serialization
|
||||
/// <summary>
|
||||
/// Convert from <cref="Models.Listrom.MetadataFile"/> to <cref="Header"/>
|
||||
/// </summary>
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel(MetadataFile item)
|
||||
private static Models.Internal.Header ConvertHeaderToInternalModel()
|
||||
{
|
||||
var header = new Models.Internal.Header
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user