Promote Driver

This commit is contained in:
Matt Nadareski
2020-09-02 15:38:10 -07:00
parent 6bf381bec9
commit e05f1df878
12 changed files with 451 additions and 132 deletions

View File

@@ -125,6 +125,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore]
public long DiskCount { get; private set; } = 0;
/// <summary>
/// Number of Driver items
/// </summary>
[JsonIgnore]
public long DriverCount { get; private set; } = 0;
/// <summary>
/// Number of Feature items
/// </summary>
@@ -539,6 +545,9 @@ namespace SabreTools.Library.DatFiles
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.Driver:
DriverCount++;
break;
case ItemType.Feature:
FeatureCount++;
break;
@@ -695,6 +704,9 @@ namespace SabreTools.Library.DatFiles
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.Driver:
DriverCount--;
break;
case ItemType.Feature:
FeatureCount--;
break;

View File

@@ -235,6 +235,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Disk:
datItem = datItemObj.ToObject<Disk>();
break;
case ItemType.Driver:
datItem = datItemObj.ToObject<Driver>();
break;
case ItemType.Feature:
datItem = datItemObj.ToObject<Feature>();
break;

View File

@@ -289,6 +289,18 @@ namespace SabreTools.Library.DatFiles
reader.Read();
break;
case "driver":
datItems.Add(new Driver
{
Status = reader.GetAttribute("status").AsSupportStatus(),
Emulation = reader.GetAttribute("emulation").AsSupportStatus(),
Cocktail = reader.GetAttribute("cocktail").AsSupportStatus(),
SaveState = reader.GetAttribute("savestate").AsSupported(),
});
reader.Read();
break;
case "feature":
datItems.Add(new Feature
{
@@ -476,22 +488,6 @@ namespace SabreTools.Library.DatFiles
reader.Skip();
break;
case "driver":
var driver = new Driver();
driver.Status = reader.GetAttribute("status");
driver.Emulation = reader.GetAttribute("emulation");
driver.Cocktail = reader.GetAttribute("cocktail");
driver.SaveState = reader.GetAttribute("savestate");
// Ensure the list exists
if (machine.Drivers == null)
machine.Drivers = new List<Driver>();
machine.Drivers.Add(driver);
reader.Read();
break;
case "device":
var device = new Device();
device.Type = reader.GetAttribute("type");
@@ -1299,21 +1295,6 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
}
}
if (datItem.Machine.Drivers != null)
{
foreach (var driver in datItem.Machine.Drivers)
{
xtw.WriteStartElement("driver");
xtw.WriteOptionalAttributeString("status", driver.Status);
xtw.WriteOptionalAttributeString("emulation", driver.Emulation);
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail);
xtw.WriteOptionalAttributeString("savestate", driver.SaveState);
// End driver
xtw.WriteEndElement();
}
}
if (datItem.Machine.Devices != null)
{
foreach (var device in datItem.Machine.Devices)
@@ -1566,6 +1547,16 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Driver:
var driver = datItem as Driver;
xtw.WriteStartElement("driver");
xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus());
xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus());
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus());
xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true));
xtw.WriteEndElement();
break;
case ItemType.Feature:
var feature = datItem as Feature;
xtw.WriteStartElement("feature");

View File

@@ -1389,6 +1389,17 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Driver:
var driver = datItem as Driver;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "driver");
xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus());
xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus());
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus());
xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true));
xtw.WriteEndElement();
break;
case ItemType.Feature:
var feature = datItem as Feature;
xtw.WriteStartElement("file");

View File

@@ -692,7 +692,7 @@ namespace SabreTools.Library.DatFiles
if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf);
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported());
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported(false));
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
xtw.WriteOptionalElementString("year", datItem.Machine.Year);

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
/// <summary>
/// This holds all of the auxiliary types needed for proper parsing
@@ -163,26 +164,6 @@ namespace SabreTools.Library.DatItems
public string VBStart { get; set; } // TODO: Int32? Float?
}
/// <summary>
/// Represents one ListXML driver
/// </summary>
/// TODO: Promote to DatItem level
[JsonObject("driver")]
public class Driver
{
[JsonProperty("status")]
public string Status { get; set; } // TODO: (good|imperfect|preliminary)
[JsonProperty("emulation")]
public string Emulation { get; set; } // TODO: (good|imperfect|preliminary)
[JsonProperty("cocktail")]
public string Cocktail { get; set; } // TODO: bool? (good|imperfect|preliminary)?
[JsonProperty("savestate")]
public string SaveState { get; set; } // TODO: (supported|unsupported)
}
/// <summary>
/// Represents one ListXML extension
/// </summary>

View File

@@ -482,6 +482,9 @@ namespace SabreTools.Library.DatItems
case ItemType.Disk:
return new Disk();
case ItemType.Driver:
return new Driver();
case ItemType.Feature:
return new Feature();
@@ -524,6 +527,7 @@ namespace SabreTools.Library.DatItems
ItemType.DeviceReference => new DeviceReference(),
ItemType.DipSwitch => new DipSwitch(),
ItemType.Disk => new Disk(),
ItemType.Driver => new Driver(),
ItemType.Feature => new Feature(),
ItemType.Media => new Media(),
ItemType.RamOption => new RamOption(),

View File

@@ -0,0 +1,248 @@
using System.Collections.Generic;
using System.Linq;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace SabreTools.Library.DatItems
{
/// <summary>
/// Represents the a driver of the machine
/// </summary>
[JsonObject("driver")]
public class Driver : DatItem
{
#region Fields
/// <summary>
/// Overall driver status
/// </summary>
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Status { get; set; }
/// <summary>
/// Driver emulation status
/// </summary>
[JsonProperty("emulation", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Emulation { get; set; }
/// <summary>
/// Cocktail orientation status
/// </summary>
[JsonProperty("cocktail", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Cocktail { get; set; }
/// <summary>
/// Save state support status
/// </summary>
[JsonProperty("savestate", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public Supported SaveState { get; set; }
#endregion
#region Accessors
/// <summary>
/// Set fields with given values
/// </summary>
/// <param name="mappings">Mappings dictionary</param>
public override void SetFields(Dictionary<Field, string> mappings)
{
// Set base fields
base.SetFields(mappings);
// Handle Feature-specific fields
if (mappings.Keys.Contains(Field.DatItem_SupportStatus))
Status = mappings[Field.DatItem_SupportStatus].AsSupportStatus();
if (mappings.Keys.Contains(Field.DatItem_EmulationStatus))
Emulation = mappings[Field.DatItem_EmulationStatus].AsSupportStatus();
if (mappings.Keys.Contains(Field.DatItem_CocktailStatus))
Cocktail = mappings[Field.DatItem_CocktailStatus].AsSupportStatus();
if (mappings.Keys.Contains(Field.DatItem_SaveStateStatus))
SaveState = mappings[Field.DatItem_SaveStateStatus].AsSupported();
}
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Driver object
/// </summary>
public Driver()
{
ItemType = ItemType.Driver;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new Driver()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
AltName = this.AltName,
AltTitle = this.AltTitle,
Original = this.Original,
OpenMSXSubType = this.OpenMSXSubType,
OpenMSXType = this.OpenMSXType,
Remark = this.Remark,
Boot = this.Boot,
Part = this.Part,
Features = this.Features,
AreaName = this.AreaName,
AreaSize = this.AreaSize,
AreaWidth = this.AreaWidth,
AreaEndianness = this.AreaEndianness,
Value = this.Value,
LoadFlag = this.LoadFlag,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Status = this.Status,
Emulation = this.Emulation,
Cocktail = this.Cocktail,
SaveState = this.SaveState,
};
}
#endregion
#region Comparision Methods
public override bool Equals(DatItem other)
{
// If we don't have a Driver, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Driver
Driver newOther = other as Driver;
// If the Feature information matches
return (Status == newOther.Status
&& Emulation == newOther.Emulation
&& Cocktail == newOther.Cocktail
&& SaveState == newOther.SaveState);
}
#endregion
#region Filtering
/// <summary>
/// Check to see if a DatItem passes the filter
/// </summary>
/// <param name="filter">Filter to check against</param>
/// <returns>True if the item passed the filter, false otherwise</returns>
public override bool PassesFilter(Filter filter)
{
// Check common fields first
if (!base.PassesFilter(filter))
return false;
// Filter on status
if (filter.DatItem_SupportStatus.MatchesPositive(SupportStatus.NULL, Status) == false)
return false;
if (filter.DatItem_SupportStatus.MatchesNegative(SupportStatus.NULL, Status) == true)
return false;
// Filter on emulation
if (filter.DatItem_EmulationStatus.MatchesPositive(SupportStatus.NULL, Emulation) == false)
return false;
if (filter.DatItem_EmulationStatus.MatchesNegative(SupportStatus.NULL, Emulation) == true)
return false;
// Filter on cocktail
if (filter.DatItem_CocktailStatus.MatchesPositive(SupportStatus.NULL, Cocktail) == false)
return false;
if (filter.DatItem_CocktailStatus.MatchesNegative(SupportStatus.NULL, Cocktail) == true)
return false;
// Filter on savestate
if (filter.DatItem_SaveStateStatus.MatchesPositive(Supported.NULL, SaveState) == false)
return false;
if (filter.DatItem_SaveStateStatus.MatchesNegative(Supported.NULL, SaveState) == true)
return false;
return true;
}
/// <summary>
/// Remove fields from the DatItem
/// </summary>
/// <param name="fields">List of Fields to remove</param>
public override void RemoveFields(List<Field> fields)
{
// Remove common fields first
base.RemoveFields(fields);
// Remove the fields
if (fields.Contains(Field.DatItem_SupportStatus))
Status = SupportStatus.NULL;
if (fields.Contains(Field.DatItem_EmulationStatus))
Emulation = SupportStatus.NULL;
if (fields.Contains(Field.DatItem_CocktailStatus))
Cocktail = SupportStatus.NULL;
if (fields.Contains(Field.DatItem_SaveStateStatus))
SaveState = Supported.NULL;
}
#endregion
#region Sorting and Merging
/// <summary>
/// Replace fields from another item
/// </summary>
/// <param name="item">DatItem to pull new information from</param>
/// <param name="fields">List of Fields representing what should be updated</param>
public override void ReplaceFields(DatItem item, List<Field> fields)
{
// Replace common fields first
base.ReplaceFields(item, fields);
// If we don't have a Driver to replace from, ignore specific fields
if (item.ItemType != ItemType.Driver)
return;
// Cast for easier access
Driver newItem = item as Driver;
// Replace the fields
if (fields.Contains(Field.DatItem_SupportStatus))
Status = newItem.Status;
if (fields.Contains(Field.DatItem_EmulationStatus))
Emulation = newItem.Emulation;
if (fields.Contains(Field.DatItem_CocktailStatus))
Cocktail = newItem.Cocktail;
if (fields.Contains(Field.DatItem_SaveStateStatus))
SaveState = newItem.SaveState;
}
#endregion
}
}

View File

@@ -240,13 +240,6 @@ namespace SabreTools.Library.DatItems
Machine_Port_Analogs,
Machine_Port_Analog_Mask,
// Drivers
Machine_Drivers,
Machine_Driver_Status,
Machine_Driver_Emulation,
Machine_Driver_Cocktail,
Machine_Driver_SaveState,
// Devices
Machine_Devices,
Machine_Device_Type,
@@ -423,12 +416,18 @@ namespace SabreTools.Library.DatItems
DatItem_Setting_Value,
DatItem_Setting_Default,
// DIP Switch.Values
// DipSwitch.Values
DatItem_Values,
DatItem_Value_Name,
DatItem_Value_Value,
DatItem_Value_Default,
// Driver
DatItem_SupportStatus,
DatItem_EmulationStatus,
DatItem_CocktailStatus,
DatItem_SaveStateStatus,
// Feature
DatItem_FeatureType,
DatItem_FeatureStatus,
@@ -496,6 +495,7 @@ namespace SabreTools.Library.DatItems
Configuration,
DeviceReference,
DipSwitch,
Driver,
Feature,
RamOption,
Release,
@@ -585,4 +585,20 @@ namespace SabreTools.Library.DatItems
Partial = 1 << 1,
Yes = 1 << 2,
}
/// <summary>
/// Determine driver support statuses
/// </summary>
[Flags]
public enum SupportStatus
{
/// <summary>
/// This is a fake flag that is used for filter only
/// </summary>
NULL = 0,
Good = 1 << 0,
Imperfect = 1 << 1,
Preliminary = 1 << 2,
}
}

View File

@@ -176,12 +176,6 @@ namespace SabreTools.Library.DatItems
[JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<Port> Ports { get; set; } = null;
/// <summary>
/// List of associated drivers
/// </summary>
[JsonProperty("drivers", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<Driver> Drivers { get; set; } = null;
/// <summary>
/// List of associated devices
/// </summary>
@@ -544,7 +538,6 @@ namespace SabreTools.Library.DatItems
Conditions = this.Conditions,
Inputs = this.Inputs,
Ports = this.Ports,
Drivers = this.Drivers,
Devices = this.Devices,
#endregion

View File

@@ -105,13 +105,6 @@ namespace SabreTools.Library.Filtering
public FilterItem<bool?> Machine_Port_Analogs { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Port_Analog_Mask { get; private set; } = new FilterItem<string>();
// Drivers
public FilterItem<bool?> Machine_Drivers { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Driver_Status { get; private set; } = new FilterItem<string>();
public FilterItem<string> Machine_Driver_Emulation { get; private set; } = new FilterItem<string>();
public FilterItem<string> Machine_Driver_Cocktail { get; private set; } = new FilterItem<string>();
public FilterItem<string> Machine_Driver_SaveState { get; private set; } = new FilterItem<string>();
// Devices
public FilterItem<bool?> Machine_Devices { get; private set; } = new FilterItem<bool?>() { Neutral = null };
public FilterItem<string> Machine_Device_Type { get; private set; } = new FilterItem<string>();
@@ -294,12 +287,17 @@ namespace SabreTools.Library.Filtering
public FilterItem<string> DatItem_Value_Value { get; private set; } = new FilterItem<string>();
public FilterItem<bool?> DatItem_Value_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
// Driver
public FilterItem<SupportStatus> DatItem_SupportStatus { get; private set; } = new FilterItem<SupportStatus>() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL };
public FilterItem<SupportStatus> DatItem_EmulationStatus { get; private set; } = new FilterItem<SupportStatus>() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL };
public FilterItem<SupportStatus> DatItem_CocktailStatus { get; private set; } = new FilterItem<SupportStatus>() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL };
public FilterItem<Supported> DatItem_SaveStateStatus { get; private set; } = new FilterItem<Supported>() { Positive = Supported.NULL, Negative = Supported.NULL };
// Feature
public FilterItem<FeatureType> DatItem_FeatureType { get; private set; } = new FilterItem<FeatureType>() { Positive = FeatureType.NULL, Negative = FeatureType.NULL };
public FilterItem<FeatureStatus> DatItem_FeatureStatus { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
public FilterItem<FeatureStatus> DatItem_FeatureOverall { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
// Ram Option
public FilterItem<string> DatItem_Content { get; private set; } = new FilterItem<string>();
@@ -846,42 +844,6 @@ namespace SabreTools.Library.Filtering
Machine_Port_Analog_Mask.PositiveSet.Add(value);
break;
// Drivers
case Field.Machine_Drivers:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
Machine_Drivers.Neutral = false;
else
Machine_Drivers.Neutral = true;
break;
case Field.Machine_Driver_Status:
if (negate)
Machine_Driver_Status.NegativeSet.Add(value);
else
Machine_Driver_Status.PositiveSet.Add(value);
break;
case Field.Machine_Driver_Emulation:
if (negate)
Machine_Driver_Emulation.NegativeSet.Add(value);
else
Machine_Driver_Emulation.PositiveSet.Add(value);
break;
case Field.Machine_Driver_Cocktail:
if (negate)
Machine_Driver_Cocktail.NegativeSet.Add(value);
else
Machine_Driver_Cocktail.PositiveSet.Add(value);
break;
case Field.Machine_Driver_SaveState:
if (negate)
Machine_Driver_SaveState.NegativeSet.Add(value);
else
Machine_Driver_SaveState.PositiveSet.Add(value);
break;
// Devices
case Field.Machine_Devices:
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
@@ -1697,6 +1659,35 @@ namespace SabreTools.Library.Filtering
DatItem_Value_Default.Neutral = true;
break;
// Driver
case Field.DatItem_SupportStatus:
if (negate)
DatItem_SupportStatus.Negative |= value.AsSupportStatus();
else
DatItem_SupportStatus.Positive |= value.AsSupportStatus();
break;
case Field.DatItem_EmulationStatus:
if (negate)
DatItem_EmulationStatus.Negative |= value.AsSupportStatus();
else
DatItem_EmulationStatus.Positive |= value.AsSupportStatus();
break;
case Field.DatItem_CocktailStatus:
if (negate)
DatItem_CocktailStatus.Negative |= value.AsSupportStatus();
else
DatItem_CocktailStatus.Positive |= value.AsSupportStatus();
break;
case Field.DatItem_SaveStateStatus:
if (negate)
DatItem_SaveStateStatus.Negative |= value.AsSupported();
else
DatItem_SaveStateStatus.Positive |= value.AsSupported();
break;
// Feature
case Field.DatItem_FeatureType:
if (negate)
@@ -1789,9 +1780,9 @@ namespace SabreTools.Library.Filtering
#endregion
#endregion // Item-Specifics
#endregion // Item-Specifics
#endregion // DatItem Filters
#endregion // DatItem Filters
}
}

View File

@@ -698,21 +698,6 @@ namespace SabreTools.Library.Tools
case "port_analog_mask":
return Field.Machine_Port_Analog_Mask;
case "drivers":
return Field.Machine_Drivers;
case "driver_status":
return Field.Machine_Driver_Status;
case "driver_emulation":
return Field.Machine_Driver_Emulation;
case "driver_cocktail":
return Field.Machine_Driver_Cocktail;
case "driver_savestate":
return Field.Machine_Driver_SaveState;
case "devices":
return Field.Machine_Devices;
@@ -1119,6 +1104,19 @@ namespace SabreTools.Library.Tools
case "value_default":
return Field.DatItem_Value_Default;
// Driver
case "supportstatus":
return Field.DatItem_SupportStatus;
case "emulationstatus":
return Field.DatItem_EmulationStatus;
case "cocktailstatus":
return Field.DatItem_CocktailStatus;
case "savestatestatus":
return Field.DatItem_SaveStateStatus;
// Feature
case "featuretype":
return Field.DatItem_FeatureType;
@@ -1683,6 +1681,8 @@ namespace SabreTools.Library.Tools
return ItemType.DipSwitch;
case "disk":
return ItemType.Disk;
case "driver":
return ItemType.Driver;
case "feature":
return ItemType.Feature;
case "media":
@@ -1716,6 +1716,7 @@ namespace SabreTools.Library.Tools
"device_ref" => ItemType.DeviceReference,
"dipswitch" => ItemType.DipSwitch,
"disk" => ItemType.Disk,
"driver" => ItemType.Driver,
"feature" => ItemType.Feature,
"media" => ItemType.Media,
"ramoption" => ItemType.RamOption,
@@ -2015,10 +2016,12 @@ namespace SabreTools.Library.Tools
switch (supported?.ToLowerInvariant())
{
case "no":
case "unsupported":
return Supported.No;
case "partial":
return Supported.Partial;
case "yes":
case "supported":
return Supported.Yes;
default:
return Supported.NULL;
@@ -2027,13 +2030,45 @@ namespace SabreTools.Library.Tools
return supported?.ToLowerInvariant() switch
{
"no" => Supported.No,
"unsupported" => Supported.No,
"partial" => Supported.Partial,
"yes" => Supported.Yes,
"supported" => Supported.Yes,
_ => Supported.NULL,
};
#endif
}
/// <summary>
/// Get SupportStatus value from input string
/// </summary>
/// <param name="supported">String to get value from</param>
/// <returns>SupportStatus value corresponding to the string</returns>
public static SupportStatus AsSupportStatus(this string supportStatus)
{
#if NET_FRAMEWORK
switch (supportStatus?.ToLowerInvariant())
{
case "good":
return SupportStatus.Good;
case "imperfect":
return SupportStatus.Imperfect;
case "preliminary":
return SupportStatus.Preliminary;
default:
return SupportStatus.NULL;
}
#else
return supportStatus?.ToLowerInvariant() switch
{
"good" => SupportStatus.Good,
"imperfect" => SupportStatus.Imperfect,
"preliminary" => SupportStatus.Preliminary,
_ => SupportStatus.NULL,
};
#endif
}
/// <summary>
/// Get bool? value from input string
/// </summary>
@@ -2251,6 +2286,8 @@ namespace SabreTools.Library.Tools
return "dipswitch";
case ItemType.Disk:
return "disk";
case ItemType.Driver:
return "driver";
case ItemType.Feature:
return "feature";
case ItemType.Media:
@@ -2284,6 +2321,7 @@ namespace SabreTools.Library.Tools
ItemType.DeviceReference => "device_ref",
ItemType.DipSwitch => "dipswitch",
ItemType.Disk => "disk",
ItemType.Driver => "driver",
ItemType.Feature => "feature",
ItemType.Media => "media",
ItemType.RamOption => "ramoption",
@@ -2611,18 +2649,19 @@ namespace SabreTools.Library.Tools
/// Get string value from input Supported
/// </summary>
/// <param name="supported">Supported to get value from</param>
/// <param name="verbose">True to use verbose output, false otherwise</param>
/// <returns>String value corresponding to the Supported</returns>
public static string FromSupported(this Supported supported)
public static string FromSupported(this Supported supported, bool verbose)
{
#if NET_FRAMEWORK
switch (supported)
{
case Supported.No:
return "no";
return verbose ? "unsupported" : "no";
case Supported.Partial:
return "partial";
case Supported.Yes:
return "yes";
return verbose ? "supported" : "yes";
default:
return null;
}
@@ -2637,6 +2676,36 @@ namespace SabreTools.Library.Tools
#endif
}
/// <summary>
/// Get string value from input SupportStatus
/// </summary>
/// <param name="supportStatus">SupportStatus to get value from</param>
/// <returns>String value corresponding to the SupportStatus</returns>
public static string FromSupportStatus(this SupportStatus supportStatus)
{
#if NET_FRAMEWORK
switch (supportStatus)
{
case SupportStatus.Good:
return "good";
case SupportStatus.Imperfect:
return "imperfect";
case SupportStatus.Preliminary:
return "preliminary";
default:
return null;
}
#else
return supportStatus switch
{
SupportStatus.Good => "good",
SupportStatus.Imperfect => "imperfect",
SupportStatus.Preliminary => "preliminary",
_ => null,
};
#endif
}
/// <summary>
/// Get string value from input bool?
/// </summary>