diff --git a/SabreTools.Library/DatFiles/ItemDictionary.cs b/SabreTools.Library/DatFiles/ItemDictionary.cs index c25ea657..4819eeed 100644 --- a/SabreTools.Library/DatFiles/ItemDictionary.cs +++ b/SabreTools.Library/DatFiles/ItemDictionary.cs @@ -101,6 +101,12 @@ namespace SabreTools.Library.DatFiles [JsonIgnore] public long ChipCount { get; private set; } = 0; + /// + /// Number of Configuration items + /// + [JsonIgnore] + public long ConfigurationCount { get; private set; } = 0; + /// /// Number of Device Reference items /// @@ -488,6 +494,9 @@ namespace SabreTools.Library.DatFiles case ItemType.Chip: ChipCount++; break; + case ItemType.Configuration: + ConfigurationCount++; + break; case ItemType.DeviceReference: DeviceReferenceCount++; break; @@ -629,6 +638,9 @@ namespace SabreTools.Library.DatFiles case ItemType.Chip: ChipCount--; break; + case ItemType.Configuration: + ConfigurationCount--; + break; case ItemType.DeviceReference: DeviceReferenceCount--; break; diff --git a/SabreTools.Library/DatFiles/Json.cs b/SabreTools.Library/DatFiles/Json.cs index 63eae6b6..3e1c22c0 100644 --- a/SabreTools.Library/DatFiles/Json.cs +++ b/SabreTools.Library/DatFiles/Json.cs @@ -223,6 +223,9 @@ namespace SabreTools.Library.DatFiles case ItemType.Chip: datItem = datItemObj.ToObject(); break; + case ItemType.Configuration: + datItem = datItemObj.ToObject(); + break; case ItemType.DeviceReference: datItem = datItemObj.ToObject(); break; diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs index cc10d586..401e77a8 100644 --- a/SabreTools.Library/DatFiles/SabreDat.cs +++ b/SabreTools.Library/DatFiles/SabreDat.cs @@ -888,6 +888,51 @@ namespace SabreTools.Library.DatFiles xtw.WriteEndElement(); break; + case ItemType.Configuration: + var configuration = datItem as Configuration; + xtw.WriteStartElement("file"); + xtw.WriteAttributeString("type", "configuration"); + xtw.WriteOptionalAttributeString("name", configuration.Name); + xtw.WriteOptionalAttributeString("tag", configuration.Tag); + xtw.WriteOptionalAttributeString("mask", configuration.Mask); + + if (configuration.Conditions != null) + { + foreach (var condition in configuration.Conditions) + { + xtw.WriteStartElement("condition"); + xtw.WriteOptionalAttributeString("tag", condition.Tag); + xtw.WriteOptionalAttributeString("mask", condition.Mask); + xtw.WriteOptionalAttributeString("relation", condition.Relation); + xtw.WriteOptionalAttributeString("value", condition.Value); + xtw.WriteEndElement(); + } + } + if (configuration.Locations != null) + { + foreach (var location in configuration.Locations) + { + xtw.WriteStartElement("conflocation"); + xtw.WriteOptionalAttributeString("name", location.Name); + xtw.WriteOptionalAttributeString("number", location.Number); + xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo()); + xtw.WriteEndElement(); + } + } + if (configuration.Settings != null) + { + foreach (var setting in configuration.Settings) + { + xtw.WriteStartElement("confsetting"); + xtw.WriteOptionalAttributeString("name", setting.Name); + xtw.WriteOptionalAttributeString("value", setting.Value); + xtw.WriteOptionalAttributeString("default", setting.Default.FromYesNo()); + xtw.WriteEndElement(); + } + } + xtw.WriteEndElement(); + break; + case ItemType.DeviceReference: xtw.WriteStartElement("file"); xtw.WriteAttributeString("type", "device_ref"); diff --git a/SabreTools.Library/DatItems/DatItem.cs b/SabreTools.Library/DatItems/DatItem.cs index 243fb1e9..96e4d2d0 100644 --- a/SabreTools.Library/DatItems/DatItem.cs +++ b/SabreTools.Library/DatItems/DatItem.cs @@ -465,6 +465,9 @@ namespace SabreTools.Library.DatItems case ItemType.Chip: return new Chip(); + case ItemType.Configuration: + return new Configuration(); + case ItemType.DeviceReference: return new DeviceReference(); diff --git a/SabreTools.Library/Tools/Converters.cs b/SabreTools.Library/Tools/Converters.cs index c9d97180..8df92d68 100644 --- a/SabreTools.Library/Tools/Converters.cs +++ b/SabreTools.Library/Tools/Converters.cs @@ -1,5 +1,4 @@ -using System.Runtime.CompilerServices; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using SabreTools.Library.DatFiles; using SabreTools.Library.DatItems; @@ -1602,6 +1601,8 @@ namespace SabreTools.Library.Tools return ItemType.Blank; case "chip": return ItemType.Chip; + case "configuration": + return ItemType.Configuration; case "device_ref": return ItemType.DeviceReference; case "disk": @@ -1629,6 +1630,7 @@ namespace SabreTools.Library.Tools "biosset" => ItemType.BiosSet, "blank" => ItemType.Blank, "chip" => ItemType.Chip, + "configuration" => ItemType.Configuration, "device_ref" => ItemType.DeviceReference, "disk" => ItemType.Disk, "media" => ItemType.Media, @@ -2038,6 +2040,8 @@ namespace SabreTools.Library.Tools return "blank"; case ItemType.Chip: return "chip"; + case ItemType.Configuration: + return "configuration"; case ItemType.DeviceReference: return "device_ref"; case ItemType.Disk: @@ -2065,6 +2069,7 @@ namespace SabreTools.Library.Tools ItemType.BiosSet => "biosset", ItemType.Blank => "blank", ItemType.Chip => "chip", + ItemType.Configuration => "configuration", ItemType.DeviceReference => "device_ref", ItemType.Disk => "disk", ItemType.Media => "media",