Add machine type analogue filtering again

This commit is contained in:
Matt Nadareski
2026-04-06 15:39:40 -04:00
parent 4772768c1f
commit 2aca55a895
3 changed files with 38 additions and 8 deletions

View File

@@ -335,6 +335,14 @@ namespace SabreTools.Metadata.Filter
/// </summary>
private static bool ParseMachineFilterId(ref string itemName, ref string fieldName)
{
// Special case for machine type
if (string.Equals(fieldName, "type", StringComparison.OrdinalIgnoreCase))
{
itemName = "machine";
fieldName = "type";
return true;
}
// Get the set of properties
var properties = GetProperties(typeof(Machine));
if (properties is null)

View File

@@ -77,6 +77,21 @@ namespace SabreTools.Metadata.Filter
/// </summary>
private bool MatchesEqual(object obj)
{
// Special case for machine type
if (obj is Machine machine
&& string.Equals(Key.ItemName, "machine", StringComparison.OrdinalIgnoreCase)
&& string.Equals(Key.FieldName, "type", StringComparison.OrdinalIgnoreCase))
{
return Value?.ToLowerInvariant() switch
{
"none" => machine.IsBios != true && machine.IsDevice != true && machine.IsMechanical != true,
"bios" => machine.IsBios == true,
"device" or "dev" => machine.IsDevice == true,
"mechanical" or "mech" => machine.IsMechanical == true,
_ => false,
};
}
// Process the check value
if (!GetCheckValue(obj, Key.FieldName, out string? checkValue))
return string.IsNullOrEmpty(Value);
@@ -119,6 +134,21 @@ namespace SabreTools.Metadata.Filter
/// </summary>
private bool MatchesNotEqual(object obj)
{
// Special case for machine type
if (obj is Machine machine
&& string.Equals(Key.ItemName, "machine", StringComparison.OrdinalIgnoreCase)
&& string.Equals(Key.FieldName, "type", StringComparison.OrdinalIgnoreCase))
{
return Value?.ToLowerInvariant() switch
{
"none" => machine.IsBios == true || machine.IsDevice == true || machine.IsMechanical == true,
"bios" => machine.IsBios != true,
"device" or "dev" => machine.IsDevice != true,
"mechanical" or "mech" => machine.IsMechanical != true,
_ => true,
};
}
// Process the check value
if (!GetCheckValue(obj, Key.FieldName, out string? checkValue))
return string.IsNullOrEmpty(Value);

View File

@@ -76,14 +76,6 @@ namespace SabreTools.Metadata.Filter
// Get the key as a string
string key = filter.Key.ToString();
// Special case for machine types
if (filter.Key.ItemName == "machine" && filter.Key.FieldName == "isbios")
key = $"{"machine"}.COMBINEDTYPE";
else if (filter.Key.ItemName == "machine" && filter.Key.FieldName == "isdevice")
key = $"{"machine"}.COMBINEDTYPE";
else if (filter.Key.ItemName == "machine" && filter.Key.FieldName == "ismechanical")
key = $"{"machine"}.COMBINEDTYPE";
// Set the expected group type
GroupType groupType = GroupType.OR;