mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Minor cleanup to avoid runtime exceptions
This commit is contained in:
@@ -1091,13 +1091,22 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
foreach (DatItem item in items)
|
foreach (DatItem item in items)
|
||||||
{
|
{
|
||||||
|
// Get the current machine
|
||||||
|
var machine = item.GetFieldValue<Machine>(DatItem.MachineKey);
|
||||||
|
if (machine == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the values to check against
|
||||||
|
string? machineName = machine.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||||
|
string? machineDesc = machine.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||||
|
if (machineName == null || machineDesc == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
// If the key mapping doesn't exist, add it
|
// If the key mapping doesn't exist, add it
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
mapping.TryAdd(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!,
|
mapping.TryAdd(machineName, machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
|
||||||
#else
|
#else
|
||||||
mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]
|
mapping[machineName] = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
||||||
= item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
|||||||
@@ -1409,6 +1409,7 @@ namespace SabreTools.DatFiles
|
|||||||
foreach (var machine in GetMachines())
|
foreach (var machine in GetMachines())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
// Get the current machine
|
||||||
if (machine.Value == null)
|
if (machine.Value == null)
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
return;
|
return;
|
||||||
@@ -1439,37 +1440,37 @@ namespace SabreTools.DatFiles
|
|||||||
Dictionary<string, string> mapping = [];
|
Dictionary<string, string> mapping = [];
|
||||||
#endif
|
#endif
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key =>
|
Parallel.ForEach(GetMachines(), Core.Globals.ParallelOptions, machine =>
|
||||||
#elif NET40_OR_GREATER
|
#elif NET40_OR_GREATER
|
||||||
Parallel.ForEach(SortedKeys, key =>
|
Parallel.ForEach(GetMachines(), machine =>
|
||||||
#else
|
#else
|
||||||
foreach (var key in SortedKeys)
|
foreach (var machine in GetMachines())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
var items = GetItemsForBucket(key);
|
// Get the current machine
|
||||||
if (items == null)
|
if (machine.Value == null)
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (var item in items)
|
// Get the values to check against
|
||||||
{
|
string? machineName = machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||||
// Get the current machine
|
string? machineDesc = machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey);
|
||||||
var machine = GetMachineForItem(item.Key);
|
if (machineName == null || machineDesc == null)
|
||||||
if (machine.Value == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// If the key mapping doesn't exist, add it
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
mapping.TryAdd(machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!,
|
return;
|
||||||
machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
|
||||||
#else
|
#else
|
||||||
mapping[machine.Value.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]
|
continue;
|
||||||
= machine.Value.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
#endif
|
||||||
|
|
||||||
|
// If the key mapping doesn't exist, add it
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
mapping.TryAdd(machineName, machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||||
|
#else
|
||||||
|
mapping[machineName] = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user