mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move MachineDescriptionToName to dictionaries
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
#endif
|
#endif
|
||||||
@@ -853,6 +854,106 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use game descriptions as names, updating cloneof/romof/sampleof
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
|
public void MachineDescriptionToName(bool throwOnError = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// First we want to get a mapping for all games to description
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
ConcurrentDictionary<string, string> mapping = new();
|
||||||
|
#else
|
||||||
|
Dictionary<string, string> mapping = [];
|
||||||
|
#endif
|
||||||
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
|
Parallel.ForEach(Keys, Globals.ParallelOptions, key =>
|
||||||
|
#elif NET40_OR_GREATER
|
||||||
|
Parallel.ForEach(Keys, key =>
|
||||||
|
#else
|
||||||
|
foreach (var key in Keys)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var items = this[key];
|
||||||
|
if (items == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
// If the key mapping doesn't exist, add it
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
mapping.TryAdd(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||||
|
#else
|
||||||
|
mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!] = item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Now we loop through every item and update accordingly
|
||||||
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
|
Parallel.ForEach(Keys, Globals.ParallelOptions, key =>
|
||||||
|
#elif NET40_OR_GREATER
|
||||||
|
Parallel.ForEach(Keys, key =>
|
||||||
|
#else
|
||||||
|
foreach (var key in Keys)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var items = this[key];
|
||||||
|
if (items == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ConcurrentList<DatItem> newItems = [];
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
// Update machine name
|
||||||
|
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!))
|
||||||
|
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]);
|
||||||
|
|
||||||
|
// Update cloneof
|
||||||
|
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!))
|
||||||
|
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!]);
|
||||||
|
|
||||||
|
// Update romof
|
||||||
|
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!))
|
||||||
|
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!]);
|
||||||
|
|
||||||
|
// Update sampleof
|
||||||
|
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!))
|
||||||
|
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!]);
|
||||||
|
|
||||||
|
// Add the new item to the output list
|
||||||
|
newItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace the old list of roms with the new one
|
||||||
|
Remove(key);
|
||||||
|
AddRange(key, newItems);
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (!throwOnError)
|
||||||
|
{
|
||||||
|
logger.Warning(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Statistics
|
#region Statistics
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#if NET40_OR_GREATER || NETCOREAPP
|
using System;
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
#endif
|
#endif
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -15,6 +16,7 @@ using SabreTools.Core.Tools;
|
|||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
using SabreTools.DatItems.Formats;
|
using SabreTools.DatItems.Formats;
|
||||||
using SabreTools.Hashing;
|
using SabreTools.Hashing;
|
||||||
|
using SabreTools.Logging;
|
||||||
using SabreTools.Matching;
|
using SabreTools.Matching;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -101,6 +103,11 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey _bucketedBy = ItemKey.NULL;
|
private ItemKey _bucketedBy = ItemKey.NULL;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logging object
|
||||||
|
/// </summary>
|
||||||
|
private readonly Logger logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
@@ -128,6 +135,14 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic constructor
|
||||||
|
/// </summary>
|
||||||
|
public ItemDictionaryDB()
|
||||||
|
{
|
||||||
|
logger = new Logger(this);
|
||||||
|
}
|
||||||
|
|
||||||
#region Accessors
|
#region Accessors
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -901,6 +916,107 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use game descriptions as names, updating cloneof/romof/sampleof
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
|
public void MachineDescriptionToName(bool throwOnError = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// First we want to get a mapping for all games to description
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
ConcurrentDictionary<string, string> mapping = new();
|
||||||
|
#else
|
||||||
|
Dictionary<string, string> mapping = [];
|
||||||
|
#endif
|
||||||
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
|
Parallel.ForEach(SortedKeys, Globals.ParallelOptions, key =>
|
||||||
|
#elif NET40_OR_GREATER
|
||||||
|
Parallel.ForEach(SortedKeys, key =>
|
||||||
|
#else
|
||||||
|
foreach (var key in SortedKeys)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var items = GetDatItemsForBucket(key);
|
||||||
|
if (items == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foreach ((long, DatItem) item in items)
|
||||||
|
{
|
||||||
|
// If the key mapping doesn't exist, add it
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
mapping.TryAdd(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!,
|
||||||
|
item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
||||||
|
#else
|
||||||
|
mapping[item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]
|
||||||
|
= item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Now we loop through every item and update accordingly
|
||||||
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
|
Parallel.ForEach(SortedKeys, Globals.ParallelOptions, key =>
|
||||||
|
#elif NET40_OR_GREATER
|
||||||
|
Parallel.ForEach(SortedKeys, key =>
|
||||||
|
#else
|
||||||
|
foreach (var key in SortedKeys)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
var items = GetDatItemsForBucket(key);
|
||||||
|
if (items == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ConcurrentList<(long, DatItem)> newItems = [];
|
||||||
|
foreach ((long, DatItem) item in items)
|
||||||
|
{
|
||||||
|
// Update machine name
|
||||||
|
if (!string.IsNullOrEmpty(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)) && mapping.ContainsKey(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!))
|
||||||
|
item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]);
|
||||||
|
|
||||||
|
// Update cloneof
|
||||||
|
if (!string.IsNullOrEmpty(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)) && mapping.ContainsKey(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!))
|
||||||
|
item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, mapping[item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!]);
|
||||||
|
|
||||||
|
// Update romof
|
||||||
|
if (!string.IsNullOrEmpty(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)) && mapping.ContainsKey(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!))
|
||||||
|
item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, mapping[item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!]);
|
||||||
|
|
||||||
|
// Update sampleof
|
||||||
|
if (!string.IsNullOrEmpty(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)) && mapping.ContainsKey(item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!))
|
||||||
|
item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, mapping[item.Item2.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!]);
|
||||||
|
|
||||||
|
// Add the new item to the output list
|
||||||
|
newItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace the old list of roms with the new one
|
||||||
|
_buckets[key] = newItems.Select(i => i.Item1).ToConcurrentList();
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (!throwOnError)
|
||||||
|
{
|
||||||
|
logger.Warning(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute all filters in a filter runner on a single bucket
|
/// Execute all filters in a filter runner on a single bucket
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
// Process description to machine name
|
// Process description to machine name
|
||||||
if (DescriptionAsName == true)
|
if (DescriptionAsName == true)
|
||||||
MachineDescriptionToName(datFile);
|
{
|
||||||
|
datFile.Items.MachineDescriptionToName(throwOnError);
|
||||||
|
datFile.ItemsDB.MachineDescriptionToName(throwOnError);
|
||||||
|
}
|
||||||
|
|
||||||
// If we are removing scene dates, do that now
|
// If we are removing scene dates, do that now
|
||||||
if (SceneDateStrip == true)
|
if (SceneDateStrip == true)
|
||||||
@@ -228,109 +231,6 @@ namespace SabreTools.Filtering
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Use game descriptions as names in the DAT, updating cloneof/romof/sampleof
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
|
||||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
|
||||||
internal void MachineDescriptionToName(DatFile datFile, bool throwOnError = false)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// First we want to get a mapping for all games to description
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
ConcurrentDictionary<string, string> concurrentDictionary = new();
|
|
||||||
ConcurrentDictionary<string, string> mapping = concurrentDictionary;
|
|
||||||
#else
|
|
||||||
Dictionary<string, string> concurrentDictionary = [];
|
|
||||||
Dictionary<string, string> mapping = concurrentDictionary;
|
|
||||||
#endif
|
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
|
||||||
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
|
|
||||||
#elif NET40_OR_GREATER
|
|
||||||
Parallel.ForEach(datFile.Items.Keys, key =>
|
|
||||||
#else
|
|
||||||
foreach (var key in datFile.Items.Keys)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
var items = datFile.Items[key];
|
|
||||||
if (items == null)
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
foreach (DatItem item in items)
|
|
||||||
{
|
|
||||||
// If the key mapping doesn't exist, add it
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
mapping.TryAdd(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!, item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -"));
|
|
||||||
#else
|
|
||||||
mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!] = item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey)!.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Now we loop through every item and update accordingly
|
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
|
||||||
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
|
|
||||||
#elif NET40_OR_GREATER
|
|
||||||
Parallel.ForEach(datFile.Items.Keys, key =>
|
|
||||||
#else
|
|
||||||
foreach (var key in datFile.Items.Keys)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
var items = datFile.Items[key];
|
|
||||||
if (items == null)
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConcurrentList<DatItem> newItems = [];
|
|
||||||
foreach (DatItem item in items)
|
|
||||||
{
|
|
||||||
// Update machine name
|
|
||||||
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!))
|
|
||||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey)!]);
|
|
||||||
|
|
||||||
// Update cloneof
|
|
||||||
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!))
|
|
||||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.CloneOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.CloneOfKey)!]);
|
|
||||||
|
|
||||||
// Update romof
|
|
||||||
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!))
|
|
||||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.RomOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.RomOfKey)!]);
|
|
||||||
|
|
||||||
// Update sampleof
|
|
||||||
if (!string.IsNullOrEmpty(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)) && mapping.ContainsKey(item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!))
|
|
||||||
item.GetFieldValue<Machine>(DatItem.MachineKey)!.SetFieldValue<string?>(Models.Metadata.Machine.SampleOfKey, mapping[item.GetFieldValue<Machine>(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.SampleOfKey)!]);
|
|
||||||
|
|
||||||
// Add the new item to the output list
|
|
||||||
newItems.Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace the old list of roms with the new one
|
|
||||||
datFile.Items.Remove(key);
|
|
||||||
datFile.Items.AddRange(key, newItems);
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
catch (Exception ex) when (!throwOnError)
|
|
||||||
{
|
|
||||||
logger.Warning(ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filter a DAT using 1G1R logic given an ordered set of regions
|
/// Filter a DAT using 1G1R logic given an ordered set of regions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user