diff --git a/SabreTools.Core/Filter/FilterObject.cs b/SabreTools.Core/Filter/FilterObject.cs
index e0ae74a0..2b96c4df 100644
--- a/SabreTools.Core/Filter/FilterObject.cs
+++ b/SabreTools.Core/Filter/FilterObject.cs
@@ -12,9 +12,14 @@ namespace SabreTools.Core.Filter
public class FilterObject
{
///
- /// Key name for the filter
+ /// Item name associated with the field
///
- public readonly string[] Key;
+ public readonly string ItemName;
+
+ ///
+ /// Field name associated with the filter
+ ///
+ public readonly string FieldName;
///
/// Value to match in the filter
@@ -31,30 +36,33 @@ namespace SabreTools.Core.Filter
if (!SplitFilterString(filterString, out var keyItem, out Operation operation, out var value))
throw new ArgumentOutOfRangeException(nameof(filterString));
- if (!FilterParser.ParseFilterId(keyItem, out var itemName, out var fieldName))
+ if (!FilterParser.ParseFilterId(keyItem, out string itemName, out string fieldName))
throw new ArgumentOutOfRangeException(nameof(filterString));
- Key = [itemName, fieldName];
+ ItemName = itemName;
+ FieldName = fieldName;
Value = value;
Operation = operation;
}
public FilterObject(string itemField, string? value, string? operation)
{
- if (!FilterParser.ParseFilterId(itemField, out var itemName, out var fieldName))
+ if (!FilterParser.ParseFilterId(itemField, out string itemName, out string fieldName))
throw new ArgumentOutOfRangeException(nameof(value));
- Key = [itemName, fieldName];
+ ItemName = itemName;
+ FieldName = fieldName;
Value = value;
Operation = GetOperation(operation);
}
public FilterObject(string itemField, string? value, Operation operation)
{
- if (!FilterParser.ParseFilterId(itemField, out var itemName, out var fieldName))
+ if (!FilterParser.ParseFilterId(itemField, out string itemName, out string fieldName))
throw new ArgumentOutOfRangeException(nameof(value));
- Key = [itemName!, fieldName!];
+ ItemName = itemName;
+ FieldName = fieldName;
Value = value;
Operation = operation;
}
@@ -66,7 +74,7 @@ namespace SabreTools.Core.Filter
///
public bool Matches(DictionaryBase dictionaryBase)
{
- // TODO: Add validation of dictionary base type from Key[0]
+ // TODO: Add validation of dictionary base type from the key values
return Operation switch
{
Operation.Equals => MatchesEqual(dictionaryBase),
@@ -85,11 +93,11 @@ namespace SabreTools.Core.Filter
private bool MatchesEqual(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return Value == null;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return Value == null;
@@ -128,11 +136,11 @@ namespace SabreTools.Core.Filter
private bool MatchesNotEqual(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return Value != null;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return Value == null;
@@ -171,11 +179,11 @@ namespace SabreTools.Core.Filter
private bool MatchesGreaterThan(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return false;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return false;
@@ -204,11 +212,11 @@ namespace SabreTools.Core.Filter
private bool MatchesGreaterThanOrEqual(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return false;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return false;
@@ -237,11 +245,11 @@ namespace SabreTools.Core.Filter
private bool MatchesLessThan(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return false;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return false;
@@ -270,11 +278,11 @@ namespace SabreTools.Core.Filter
private bool MatchesLessThanOrEqual(DictionaryBase dictionaryBase)
{
// If the key doesn't exist, we count it as null
- if (!dictionaryBase.ContainsKey(Key[1]))
+ if (!dictionaryBase.ContainsKey(FieldName))
return false;
// If the value in the dictionary is null
- string? checkValue = dictionaryBase.ReadString(Key[1]);
+ string? checkValue = dictionaryBase.ReadString(FieldName);
if (checkValue == null)
return false;
diff --git a/SabreTools.Core/Filter/FilterRunner.cs b/SabreTools.Core/Filter/FilterRunner.cs
index 32e19503..0430fb90 100644
--- a/SabreTools.Core/Filter/FilterRunner.cs
+++ b/SabreTools.Core/Filter/FilterRunner.cs
@@ -54,9 +54,9 @@ namespace SabreTools.Core.Filter
foreach (var filter in Filters)
{
// If the filter isn't for this object type, skip
- if (filter.Key[0] != itemName)
+ if (filter.ItemName != itemName)
continue;
- else if (filter.Key[0] == "item" && Array.IndexOf(TypeHelper.GetDatItemTypeNames(), itemName) > -1)
+ else if (filter.ItemName == "item" && Array.IndexOf(TypeHelper.GetDatItemTypeNames(), itemName) > -1)
continue;
// If we don't get a match, it's a failure
diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs
index 0313e105..a5a86035 100644
--- a/SabreTools.DatItems/DatItem.cs
+++ b/SabreTools.DatItems/DatItem.cs
@@ -145,10 +145,12 @@ namespace SabreTools.DatItems
FileTypes.Archives.TapeArchive => new Rom(baseFile),
FileTypes.Archives.XZArchive => new Rom(baseFile),
FileTypes.Archives.ZipArchive => new Rom(baseFile),
+ FileTypes.BaseArchive => new Rom(baseFile),
+ FileTypes.Folder => null, // Folders cannot be a DatItem
+ FileTypes.BaseFile => new Rom(baseFile),
// Miscellaneous
- null => null,
- _ => new Rom(baseFile),
+ _ => null,
};
}
diff --git a/SabreTools.Test/Filter/PopulationTests.cs b/SabreTools.Test/Filter/PopulationTests.cs
index 7a79cf5b..e54c6256 100644
--- a/SabreTools.Test/Filter/PopulationTests.cs
+++ b/SabreTools.Test/Filter/PopulationTests.cs
@@ -43,11 +43,13 @@ namespace SabreTools.Test.Filter
var filter = new FilterRunner(filters);
// Check the filters
- Assert.Equal(new string[] {"machine", "name"}, filter.Filters[0].Key);
+ Assert.Equal("machine", filter.Filters[0].ItemName);
+ Assert.Equal("name", filter.Filters[0].FieldName);
Assert.Equal("foo", filter.Filters[0].Value);
Assert.Equal(Operation.Equals, filter.Filters[0].Operation);
- Assert.Equal(new string[] {"machine", "name"}, filter.Filters[1].Key);
+ Assert.Equal("machine", filter.Filters[1].ItemName);
+ Assert.Equal("name", filter.Filters[1].FieldName);
Assert.Equal("bar", filter.Filters[1].Value);
Assert.Equal(Operation.NotEquals, filter.Filters[1].Operation);
}
@@ -66,11 +68,13 @@ namespace SabreTools.Test.Filter
var filter = new FilterRunner(filters);
// Check the filters
- Assert.Equal(new string[] { "rom", "name"}, filter.Filters[0].Key);
+ Assert.Equal("rom", filter.Filters[0].ItemName);
+ Assert.Equal("name", filter.Filters[0].FieldName);
Assert.Equal("foo", filter.Filters[0].Value);
Assert.Equal(Operation.Equals, filter.Filters[0].Operation);
- Assert.Equal(new string[] { "item", "name"}, filter.Filters[1].Key);
+ Assert.Equal("item", filter.Filters[1].ItemName);
+ Assert.Equal("name", filter.Filters[1].FieldName);
Assert.Equal("bar", filter.Filters[1].Value);
Assert.Equal(Operation.NotEquals, filter.Filters[1].Operation);
}
diff --git a/SabreTools.Test/Filtering/CleaningTests.cs b/SabreTools.Test/Filtering/CleaningTests.cs
index 2e7a5f33..f8afcd0d 100644
--- a/SabreTools.Test/Filtering/CleaningTests.cs
+++ b/SabreTools.Test/Filtering/CleaningTests.cs
@@ -67,7 +67,7 @@ namespace SabreTools.Test.Filtering
// Check the fields
Assert.Equal("name", datItem.GetName());
Assert.Equal("!", datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.NameKey));
- Assert.Equal("name-3", datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey));
+ Assert.Equal("!", datItem.GetFieldValue(DatItem.MachineKey)!.GetStringFieldValue(Models.Metadata.Machine.DescriptionKey));
}
[Theory]