Mandatory is technically numeric

This commit is contained in:
Matt Nadareski
2020-09-07 12:34:18 -07:00
parent 712f98fa32
commit 1494e0693f
4 changed files with 11 additions and 9 deletions

View File

@@ -276,7 +276,7 @@ namespace SabreTools.Library.DatFiles
DeviceType = reader.GetAttribute("type").AsDeviceType(), DeviceType = reader.GetAttribute("type").AsDeviceType(),
Tag = reader.GetAttribute("tag"), Tag = reader.GetAttribute("tag"),
FixedImage = reader.GetAttribute("fixed_image"), FixedImage = reader.GetAttribute("fixed_image"),
Mandatory = reader.GetAttribute("mandatory"), Mandatory = Sanitizer.CleanLong(reader.GetAttribute("mandatory")),
Interface = reader.GetAttribute("interface"), Interface = reader.GetAttribute("interface"),
Source = new Source Source = new Source
@@ -1421,7 +1421,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType()); xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType());
xtw.WriteOptionalAttributeString("tag", device.Tag); xtw.WriteOptionalAttributeString("tag", device.Tag);
xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage); xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage);
xtw.WriteOptionalAttributeString("mandatory", device.Mandatory); xtw.WriteOptionalAttributeString("mandatory", device.Mandatory?.ToString());
xtw.WriteOptionalAttributeString("interface", device.Interface); xtw.WriteOptionalAttributeString("interface", device.Interface);
if (device.Instances != null) if (device.Instances != null)
{ {

View File

@@ -1324,7 +1324,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType()); xtw.WriteOptionalAttributeString("type", device.DeviceType.FromDeviceType());
xtw.WriteOptionalAttributeString("tag", device.Tag); xtw.WriteOptionalAttributeString("tag", device.Tag);
xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage); xtw.WriteOptionalAttributeString("fixed_image", device.FixedImage);
xtw.WriteOptionalAttributeString("mandatory", device.Mandatory); xtw.WriteOptionalAttributeString("mandatory", device.Mandatory?.ToString());
xtw.WriteOptionalAttributeString("interface", device.Interface); xtw.WriteOptionalAttributeString("interface", device.Interface);
if (device.Instances != null) if (device.Instances != null)
{ {

View File

@@ -38,7 +38,7 @@ namespace SabreTools.Library.DatItems
/// </summary> /// </summary>
/// <remarks>Only value used seems to be 1. Used like bool, but actually int</remarks> /// <remarks>Only value used seems to be 1. Used like bool, but actually int</remarks>
[JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Mandatory { get; set; } // TODO: long? public long? Mandatory { get; set; }
/// <summary> /// <summary>
/// Device interface /// Device interface
@@ -82,7 +82,7 @@ namespace SabreTools.Library.DatItems
FixedImage = mappings[Field.DatItem_FixedImage]; FixedImage = mappings[Field.DatItem_FixedImage];
if (mappings.Keys.Contains(Field.DatItem_Mandatory)) 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)) if (mappings.Keys.Contains(Field.DatItem_Interface))
Interface = mappings[Field.DatItem_Interface]; Interface = mappings[Field.DatItem_Interface];
@@ -218,9 +218,11 @@ namespace SabreTools.Library.DatItems
return false; return false;
// Filter on mandatory // Filter on mandatory
if (filter.DatItem_Mandatory.MatchesPositiveSet(Mandatory) == false) if (filter.DatItem_Mandatory.MatchesNeutral(null, Mandatory) == false)
return 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; return false;
// Filter on interface // Filter on interface

View File

@@ -191,7 +191,7 @@ namespace SabreTools.Library.Filtering
// Device // Device
public FilterItem<DeviceType> DatItem_DeviceType { get; private set; } = new FilterItem<DeviceType>() { Positive = DeviceType.NULL, Negative = DeviceType.NULL }; public FilterItem<DeviceType> DatItem_DeviceType { get; private set; } = new FilterItem<DeviceType>() { Positive = DeviceType.NULL, Negative = DeviceType.NULL };
public FilterItem<string> DatItem_FixedImage { get; private set; } = new FilterItem<string>(); public FilterItem<string> DatItem_FixedImage { get; private set; } = new FilterItem<string>();
public FilterItem<string> DatItem_Mandatory { get; private set; } = new FilterItem<string>(); public FilterItem<long?> DatItem_Mandatory { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
public FilterItem<string> DatItem_Interface { get; private set; } = new FilterItem<string>(); public FilterItem<string> DatItem_Interface { get; private set; } = new FilterItem<string>();
// Display // Display
@@ -826,7 +826,7 @@ namespace SabreTools.Library.Filtering
break; break;
case Field.DatItem_Mandatory: case Field.DatItem_Mandatory:
SetStringFilter(DatItem_Mandatory, value, negate); SetLongFilter(DatItem_Mandatory, value, negate);
break; break;
case Field.DatItem_Interface: case Field.DatItem_Interface: