Change Supported to Enum

This commit is contained in:
Matt Nadareski
2020-08-22 13:31:13 -07:00
parent b30173ba55
commit d4be402380
9 changed files with 196 additions and 68 deletions

View File

@@ -45,37 +45,58 @@ namespace SabreTools.Library.DatItems
#endregion
#region SoftwareList
#region ListXML
/// <summary>
/// Represents one SoftwareList dipswitch
/// Represents one ListXML dipswitch
/// </summary>
public class SoftwareListDipSwitch
/// <remarks>Also used by SoftwareList</remarks>
public class ListXMLDipSwitch
{
public string Name { get; set; }
public string Tag { get; set; }
public string Mask { get; set; }
public List<SoftwareListDipValue> Values { get; set; }
public List<ListXMLDipLocation> Locations { get; set; }
public List<ListXMLDipValue> Values { get; set; }
public SoftwareListDipSwitch(string name, string tag, string mask)
public ListXMLDipSwitch(string name, string tag, string mask)
{
Name = name;
Tag = tag;
Mask = mask;
Values = new List<SoftwareListDipValue>();
Locations = new List<ListXMLDipLocation>();
Values = new List<ListXMLDipValue>();
}
}
/// <summary>
/// Represents one SoftwareList dipswitch
/// Represents one ListXML diplocation
/// </summary>
public class SoftwareListDipValue
public class ListXMLDipLocation
{
public string Name { get; set; }
public string Number { get; set; }
public bool? Inverted { get; set; }
public ListXMLDipLocation(string name, string number, bool? inverted)
{
Name = name;
Number = number;
Inverted = inverted;
}
}
/// <summary>
/// Represents one ListXML dipvalue
/// </summary>
/// <remarks>Also used by SoftwareList</remarks>
public class ListXMLDipValue
{
public string Name { get; set; }
public string Value { get; set; }
public bool? Default { get; set; }
public SoftwareListDipValue(string name, string value, bool? def)
public ListXMLDipValue(string name, string value, bool? def)
{
Name = name;
Value = value;
@@ -83,6 +104,10 @@ namespace SabreTools.Library.DatItems
}
}
#endregion
#region SoftwareList
/// <summary>
/// Represents one SoftwareList shared feature object
/// </summary>

View File

@@ -240,4 +240,16 @@ namespace SabreTools.Library.DatItems
Device = 1 << 2,
Mechanical = 1 << 3,
}
/// <summary>
/// Determine machine support status
/// </summary>
[Flags]
public enum Supported
{
NULL,
No,
Partial,
Yes,
}
}

View File

@@ -272,9 +272,8 @@ namespace SabreTools.Library.DatItems
/// <summary>
/// Support status
/// </summary>
/// <remarks>yes = true, partial = null, no = false</remarks>
[JsonProperty("supported")]
public bool? Supported { get; set; } = true;
public Supported Supported { get; set; } = Supported.NULL;
/// <summary>
/// List of shared feature items
@@ -287,7 +286,7 @@ namespace SabreTools.Library.DatItems
/// </summary>
/// <remarks>Also in SoftwareList</remarks>
[JsonProperty("dipswitches")]
public List<SoftwareListDipSwitch> DipSwitches { get; set; } = null;
public List<ListXMLDipSwitch> DipSwitches { get; set; } = null;
#endregion
@@ -451,7 +450,7 @@ namespace SabreTools.Library.DatItems
#region SoftwareList
case Field.Supported:
fieldValue = Supported?.ToString();
fieldValue = Supported.ToString();
break;
case Field.SharedFeatures:
fieldValue = string.Join(";", (SharedFeatures ?? new List<SoftwareListSharedFeature>()).Select(i => $"{i.Name}={i.Value}"));
@@ -640,7 +639,7 @@ namespace SabreTools.Library.DatItems
#region SoftwareList
if (mappings.Keys.Contains(Field.Supported))
Supported = mappings[Field.Supported].AsYesNo();
Supported = mappings[Field.Supported].AsSupported();
if (mappings.Keys.Contains(Field.SharedFeatures))
{
@@ -658,7 +657,7 @@ namespace SabreTools.Library.DatItems
if (mappings.Keys.Contains(Field.DipSwitches))
{
if (DipSwitches == null)
DipSwitches = new List<SoftwareListDipSwitch>();
DipSwitches = new List<ListXMLDipSwitch>();
// TODO: There's no way this will work... just create the new list for now
}
@@ -1058,7 +1057,9 @@ namespace SabreTools.Library.DatItems
#region SoftwareList
// Filter on supported
if (filter.Supported.MatchesNeutral(null, Supported) == false)
if (filter.SupportedStatus.MatchesPositive(Supported.NULL, Supported) == false)
return false;
if (filter.SupportedStatus.MatchesNegative(Supported.NULL, Supported) == true)
return false;
#endregion
@@ -1210,7 +1211,7 @@ namespace SabreTools.Library.DatItems
#region SoftwareList
if (fields.Contains(Field.Supported))
Supported = null;
Supported = Supported.NULL;
if (fields.Contains(Field.SharedFeatures))
SharedFeatures = null;