mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Rename a class and add a note
This commit is contained in:
@@ -10,6 +10,7 @@ using SabreTools.Library.DatItems;
|
|||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
|
// TODO: Use softwarelist.dtd and *try* to make this write more correctly
|
||||||
namespace SabreTools.Library.DatFiles
|
namespace SabreTools.Library.DatFiles
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -251,7 +252,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
areaEndinaness;
|
areaEndinaness;
|
||||||
long? areasize = null;
|
long? areasize = null;
|
||||||
SoftwareListPart part = null;
|
SoftwareListPart part = null;
|
||||||
List<SoftwareListFeature> features = null;
|
List<PartFeature> features = null;
|
||||||
List<DatItem> items = new List<DatItem>();
|
List<DatItem> items = new List<DatItem>();
|
||||||
|
|
||||||
while (!reader.EOF)
|
while (!reader.EOF)
|
||||||
@@ -283,13 +284,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "feature":
|
case "feature":
|
||||||
var feature = new SoftwareListFeature();
|
var feature = new PartFeature();
|
||||||
feature.Name = reader.GetAttribute("name");
|
feature.Name = reader.GetAttribute("name");
|
||||||
feature.Value = reader.GetAttribute("value");
|
feature.Value = reader.GetAttribute("value");
|
||||||
|
|
||||||
// Ensure the list exists
|
// Ensure the list exists
|
||||||
if (features == null)
|
if (features == null)
|
||||||
features = new List<SoftwareListFeature>();
|
features = new List<PartFeature>();
|
||||||
|
|
||||||
features.Add(feature);
|
features.Add(feature);
|
||||||
|
|
||||||
@@ -661,9 +662,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteStartElement("softwarelist");
|
xtw.WriteStartElement("softwarelist");
|
||||||
xtw.WriteRequiredAttributeString("name", Header.Name);
|
xtw.WriteRequiredAttributeString("name", Header.Name);
|
||||||
xtw.WriteRequiredAttributeString("description", Header.Description);
|
xtw.WriteRequiredAttributeString("description", Header.Description);
|
||||||
xtw.WriteOptionalAttributeString("forcepacking", Header.ForcePacking.FromPackingFlag(false));
|
|
||||||
xtw.WriteOptionalAttributeString("forcemerging", Header.ForceMerging.FromMergingFlag(false));
|
|
||||||
xtw.WriteOptionalAttributeString("forcenodump", Header.ForceNodump.FromNodumpFlag());
|
|
||||||
|
|
||||||
xtw.Flush();
|
xtw.Flush();
|
||||||
}
|
}
|
||||||
@@ -692,16 +690,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Build the state
|
// Build the state
|
||||||
xtw.WriteStartElement("software");
|
xtw.WriteStartElement("software");
|
||||||
xtw.WriteRequiredAttributeString("name", datItem.Machine.Name);
|
xtw.WriteRequiredAttributeString("name", datItem.Machine.Name);
|
||||||
|
|
||||||
if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||||
xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf);
|
xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf);
|
||||||
|
|
||||||
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported(false));
|
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported(false));
|
||||||
|
|
||||||
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
|
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
|
||||||
xtw.WriteOptionalElementString("year", datItem.Machine.Year);
|
xtw.WriteOptionalElementString("year", datItem.Machine.Year);
|
||||||
xtw.WriteOptionalElementString("publisher", datItem.Machine.Publisher);
|
xtw.WriteOptionalElementString("publisher", datItem.Machine.Publisher);
|
||||||
xtw.WriteOptionalElementString("category", datItem.Machine.Category);
|
|
||||||
|
|
||||||
xtw.Flush();
|
xtw.Flush();
|
||||||
}
|
}
|
||||||
@@ -751,21 +746,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
ProcessItemName(datItem, true);
|
ProcessItemName(datItem, true);
|
||||||
|
|
||||||
// Build the state
|
// Build the state
|
||||||
xtw.WriteStartElement("part");
|
|
||||||
xtw.WriteRequiredAttributeString("name", datItem.Part?.Name);
|
|
||||||
xtw.WriteRequiredAttributeString("interface", datItem.Part?.Interface);
|
|
||||||
|
|
||||||
if (datItem.Features != null && datItem.Features.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (SoftwareListFeature kvp in datItem.Features)
|
|
||||||
{
|
|
||||||
xtw.WriteStartElement("feature");
|
|
||||||
xtw.WriteRequiredAttributeString("name", kvp.Name);
|
|
||||||
xtw.WriteRequiredAttributeString("value", kvp.Value);
|
|
||||||
xtw.WriteEndElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string areaName = datItem.AreaName;
|
string areaName = datItem.AreaName;
|
||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
@@ -794,6 +774,21 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (string.IsNullOrWhiteSpace(areaName))
|
if (string.IsNullOrWhiteSpace(areaName))
|
||||||
areaName = "cdrom";
|
areaName = "cdrom";
|
||||||
|
|
||||||
|
xtw.WriteStartElement("part");
|
||||||
|
xtw.WriteRequiredAttributeString("name", datItem.Part?.Name);
|
||||||
|
xtw.WriteRequiredAttributeString("interface", datItem.Part?.Interface);
|
||||||
|
|
||||||
|
if (datItem.Features != null && datItem.Features.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (PartFeature partFeature in datItem.Features)
|
||||||
|
{
|
||||||
|
xtw.WriteStartElement("feature");
|
||||||
|
xtw.WriteRequiredAttributeString("name", partFeature.Name);
|
||||||
|
xtw.WriteRequiredAttributeString("value", partFeature.Value);
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xtw.WriteStartElement("diskarea");
|
xtw.WriteStartElement("diskarea");
|
||||||
xtw.WriteRequiredAttributeString("name", areaName);
|
xtw.WriteRequiredAttributeString("name", areaName);
|
||||||
xtw.WriteOptionalAttributeString("size", disk.AreaSize.ToString());
|
xtw.WriteOptionalAttributeString("size", disk.AreaSize.ToString());
|
||||||
@@ -808,6 +803,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
// End diskarea
|
// End diskarea
|
||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
|
|
||||||
|
// End part
|
||||||
|
xtw.WriteEndElement();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Info:
|
case ItemType.Info:
|
||||||
@@ -823,6 +821,21 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (string.IsNullOrWhiteSpace(areaName))
|
if (string.IsNullOrWhiteSpace(areaName))
|
||||||
areaName = "rom";
|
areaName = "rom";
|
||||||
|
|
||||||
|
xtw.WriteStartElement("part");
|
||||||
|
xtw.WriteRequiredAttributeString("name", datItem.Part?.Name);
|
||||||
|
xtw.WriteRequiredAttributeString("interface", datItem.Part?.Interface);
|
||||||
|
|
||||||
|
if (datItem.Features != null && datItem.Features.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (PartFeature kvp in datItem.Features)
|
||||||
|
{
|
||||||
|
xtw.WriteStartElement("feature");
|
||||||
|
xtw.WriteRequiredAttributeString("name", kvp.Name);
|
||||||
|
xtw.WriteRequiredAttributeString("value", kvp.Value);
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xtw.WriteStartElement("dataarea");
|
xtw.WriteStartElement("dataarea");
|
||||||
xtw.WriteRequiredAttributeString("name", areaName);
|
xtw.WriteRequiredAttributeString("name", areaName);
|
||||||
xtw.WriteOptionalAttributeString("size", rom.AreaSize.ToString());
|
xtw.WriteOptionalAttributeString("size", rom.AreaSize.ToString());
|
||||||
@@ -849,6 +862,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
// End dataarea
|
// End dataarea
|
||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
|
|
||||||
|
// End part
|
||||||
|
xtw.WriteEndElement();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.SharedFeature:
|
case ItemType.SharedFeature:
|
||||||
@@ -860,9 +876,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// End part
|
|
||||||
xtw.WriteEndElement();
|
|
||||||
|
|
||||||
xtw.Flush();
|
xtw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents one SoftwareList feature object
|
/// Represents one SoftwareList feature object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject("feature")]
|
/// TODO: Promote this to DatItem
|
||||||
public class SoftwareListFeature
|
[JsonObject("part_feature")]
|
||||||
|
public class PartFeature
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
/// Features provided to/by the item
|
/// Features provided to/by the item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public List<SoftwareListFeature> Features { get; set; }
|
public List<PartFeature> Features { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Original hardware part name within an item
|
/// Original hardware part name within an item
|
||||||
|
|||||||
Reference in New Issue
Block a user