diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs
index b2cb6a31..fe3f2253 100644
--- a/SabreTools.Library/DatFiles/Listxml.cs
+++ b/SabreTools.Library/DatFiles/Listxml.cs
@@ -276,7 +276,7 @@ namespace SabreTools.Library.DatFiles
DeviceType = reader.GetAttribute("type").AsDeviceType(),
Tag = reader.GetAttribute("tag"),
FixedImage = reader.GetAttribute("fixed_image"),
- Mandatory = reader.GetAttribute("mandatory"),
+ Mandatory = Sanitizer.CleanLong(reader.GetAttribute("mandatory")),
Interface = reader.GetAttribute("interface"),
Source = new Source
@@ -1421,7 +1421,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType());
xtw.WriteOptionalAttributeString("tag", device.Tag);
xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage);
- xtw.WriteOptionalAttributeString("mandatory", device.Mandatory);
+ xtw.WriteOptionalAttributeString("mandatory", device.Mandatory?.ToString());
xtw.WriteOptionalAttributeString("interface", device.Interface);
if (device.Instances != null)
{
diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs
index c050ad13..e06e5c5b 100644
--- a/SabreTools.Library/DatFiles/SabreDat.cs
+++ b/SabreTools.Library/DatFiles/SabreDat.cs
@@ -1324,7 +1324,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType());
xtw.WriteOptionalAttributeString("tag", device.Tag);
xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage);
- xtw.WriteOptionalAttributeString("mandatory", device.Mandatory);
+ xtw.WriteOptionalAttributeString("mandatory", device.Mandatory?.ToString());
xtw.WriteOptionalAttributeString("interface", device.Interface);
if (device.Instances != null)
{
diff --git a/SabreTools.Library/DatItems/Device.cs b/SabreTools.Library/DatItems/Device.cs
index 0850a991..d214fbf9 100644
--- a/SabreTools.Library/DatItems/Device.cs
+++ b/SabreTools.Library/DatItems/Device.cs
@@ -38,7 +38,7 @@ namespace SabreTools.Library.DatItems
///
/// Only value used seems to be 1. Used like bool, but actually int
[JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore)]
- public string Mandatory { get; set; } // TODO: long?
+ public long? Mandatory { get; set; }
///
/// Device interface
@@ -82,7 +82,7 @@ namespace SabreTools.Library.DatItems
FixedImage = mappings[Field.DatItem_FixedImage];
if (mappings.Keys.Contains(Field.DatItem_Mandatory))
- Mandatory = mappings[Field.DatItem_Mandatory];
+ Mandatory = Sanitizer.CleanLong(mappings[Field.DatItem_Mandatory]);
if (mappings.Keys.Contains(Field.DatItem_Interface))
Interface = mappings[Field.DatItem_Interface];
@@ -218,9 +218,11 @@ namespace SabreTools.Library.DatItems
return false;
// Filter on mandatory
- if (filter.DatItem_Mandatory.MatchesPositiveSet(Mandatory) == false)
+ if (filter.DatItem_Mandatory.MatchesNeutral(null, Mandatory) == false)
return false;
- if (filter.DatItem_Mandatory.MatchesNegativeSet(Mandatory) == true)
+ else if (filter.DatItem_Mandatory.MatchesPositive(null, Mandatory) == false)
+ return false;
+ else if (filter.DatItem_Mandatory.MatchesNegative(null, Mandatory) == false)
return false;
// Filter on interface
diff --git a/SabreTools.Library/Filtering/Filter.cs b/SabreTools.Library/Filtering/Filter.cs
index 13db577a..b8ae8df3 100644
--- a/SabreTools.Library/Filtering/Filter.cs
+++ b/SabreTools.Library/Filtering/Filter.cs
@@ -191,7 +191,7 @@ namespace SabreTools.Library.Filtering
// Device
public FilterItem DatItem_DeviceType { get; private set; } = new FilterItem() { Positive = DeviceType.NULL, Negative = DeviceType.NULL };
public FilterItem DatItem_FixedImage { get; private set; } = new FilterItem();
- public FilterItem DatItem_Mandatory { get; private set; } = new FilterItem();
+ public FilterItem DatItem_Mandatory { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null };
public FilterItem DatItem_Interface { get; private set; } = new FilterItem();
// Display
@@ -826,7 +826,7 @@ namespace SabreTools.Library.Filtering
break;
case Field.DatItem_Mandatory:
- SetStringFilter(DatItem_Mandatory, value, negate);
+ SetLongFilter(DatItem_Mandatory, value, negate);
break;
case Field.DatItem_Interface: