mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add gross hack because isbios, isdevice, and ismechanical are separate
This commit is contained in:
@@ -20,6 +20,17 @@ namespace SabreTools.Core.Filter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly string[] _datItemTypeNames = TypeHelper.GetDatItemTypeNames();
|
private readonly string[] _datItemTypeNames = TypeHelper.GetDatItemTypeNames();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set of machine type keys that are logically grouped
|
||||||
|
/// </summary>
|
||||||
|
/// TODO: REMOVE THISWHEN A PROPER IMPLEMENTATION IS FOUND
|
||||||
|
private readonly string[] _machineTypeKeys =
|
||||||
|
[
|
||||||
|
$"{MetadataFile.MachineKey}.{Machine.IsBiosKey}",
|
||||||
|
$"{MetadataFile.MachineKey}.{Machine.IsDeviceKey}",
|
||||||
|
$"{MetadataFile.MachineKey}.{Machine.IsMechanicalKey}",
|
||||||
|
];
|
||||||
|
|
||||||
public FilterRunner(FilterObject[] filters)
|
public FilterRunner(FilterObject[] filters)
|
||||||
{
|
{
|
||||||
Filters = filters;
|
Filters = filters;
|
||||||
@@ -73,6 +84,46 @@ namespace SabreTools.Core.Filter
|
|||||||
filterDictionary[key].Add(filter);
|
filterDictionary[key].Add(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: REMOVE THIS ENTIRE BLOCK WHEN A PROPER IMPLEMENTATION IS FOUND
|
||||||
|
// Handle special keys that work in tandem
|
||||||
|
if (itemName == MetadataFile.MachineKey)
|
||||||
|
{
|
||||||
|
// Check that one of the special keys exists
|
||||||
|
bool containsKey = false;
|
||||||
|
foreach (string key in _machineTypeKeys)
|
||||||
|
{
|
||||||
|
if (filterDictionary.ContainsKey(key))
|
||||||
|
containsKey = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If at least one exists
|
||||||
|
if (containsKey)
|
||||||
|
{
|
||||||
|
bool matchAny = false;
|
||||||
|
foreach (string filterKey in _machineTypeKeys)
|
||||||
|
{
|
||||||
|
// Skip missing keys
|
||||||
|
if (!filterDictionary.ContainsKey(filterKey))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var filter in filterDictionary[filterKey])
|
||||||
|
{
|
||||||
|
matchAny |= filter.Matches(dictionaryBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't get a match, it's a failure
|
||||||
|
if (!matchAny)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove the keys from the dictionary
|
||||||
|
foreach (string key in _machineTypeKeys)
|
||||||
|
{
|
||||||
|
filterDictionary.Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through and run each filter in order
|
// Loop through and run each filter in order
|
||||||
foreach (var filterKey in filterDictionary.Keys)
|
foreach (var filterKey in filterDictionary.Keys)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user