mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix consistency issues in converting to metadata
This commit is contained in:
@@ -33,6 +33,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Adjuster() : base() { }
|
||||
|
||||
public Adjuster(Models.Metadata.Adjuster item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -46,5 +47,21 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Adjuster GetInternalClone()
|
||||
{
|
||||
var adjusterItem = base.GetInternalClone();
|
||||
|
||||
var condition = GetFieldValue<Condition?>(Models.Metadata.Adjuster.ConditionKey);
|
||||
if (condition != null)
|
||||
adjusterItem[Models.Metadata.Adjuster.ConditionKey] = condition.GetInternalClone();
|
||||
|
||||
return adjusterItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Analog() : base() { }
|
||||
|
||||
public Analog(Models.Metadata.Analog item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Archive() : base() { }
|
||||
|
||||
public Archive(Models.Metadata.Archive item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public BiosSet() : base() { }
|
||||
|
||||
public BiosSet(Models.Metadata.BiosSet item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Chip() : base() { }
|
||||
|
||||
public Chip(Models.Metadata.Chip item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Condition() : base() { }
|
||||
|
||||
public Condition(Models.Metadata.Condition item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public ConfLocation() : base() { }
|
||||
|
||||
public ConfLocation(Models.Metadata.ConfLocation item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public ConfSetting() : base() { }
|
||||
|
||||
public ConfSetting(Models.Metadata.ConfSetting item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -46,5 +47,22 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.ConfSetting GetInternalClone()
|
||||
{
|
||||
var confSettingItem = base.GetInternalClone();
|
||||
|
||||
// Handle subitems
|
||||
var condition = GetFieldValue<Condition>(Models.Metadata.ConfSetting.ConditionKey);
|
||||
if (condition != null)
|
||||
confSettingItem[Models.Metadata.ConfSetting.ConditionKey] = condition.GetInternalClone();
|
||||
|
||||
return confSettingItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Configuration() : base() { }
|
||||
|
||||
public Configuration(Models.Metadata.Configuration item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
@@ -77,5 +78,35 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Configuration GetInternalClone()
|
||||
{
|
||||
var configurationItem = base.GetInternalClone();
|
||||
|
||||
var condition = GetFieldValue<Condition?>(Models.Metadata.Configuration.ConditionKey);
|
||||
if (condition != null)
|
||||
configurationItem[Models.Metadata.Configuration.ConditionKey] = condition.GetInternalClone();
|
||||
|
||||
var confLocations = GetFieldValue<ConfLocation[]?>(Models.Metadata.Configuration.ConfLocationKey);
|
||||
if (confLocations != null)
|
||||
{
|
||||
Models.Metadata.ConfLocation[] confLocationItems = Array.ConvertAll(confLocations, confLocation => confLocation.GetInternalClone());
|
||||
configurationItem[Models.Metadata.Configuration.ConfLocationKey] = confLocationItems;
|
||||
}
|
||||
|
||||
var confSettings = GetFieldValue<ConfSetting[]?>(Models.Metadata.Configuration.ConfSettingKey);
|
||||
if (confSettings != null)
|
||||
{
|
||||
Models.Metadata.ConfSetting[] confSettingItems = Array.ConvertAll(confSettings, confSetting => confSetting.GetInternalClone());
|
||||
configurationItem[Models.Metadata.Configuration.ConfSettingKey] = confSettingItems;
|
||||
}
|
||||
|
||||
return configurationItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Control() : base() { }
|
||||
|
||||
public Control(Models.Metadata.Control item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DataArea() : base() { }
|
||||
|
||||
public DataArea(Models.Metadata.DataArea item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Device() : base() { }
|
||||
|
||||
public Device(Models.Metadata.Device item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -67,5 +68,28 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Device GetInternalClone()
|
||||
{
|
||||
var deviceItem = base.GetInternalClone();
|
||||
|
||||
var instance = GetFieldValue<Instance?>(Models.Metadata.Device.InstanceKey);
|
||||
if (instance != null)
|
||||
deviceItem[Models.Metadata.Device.InstanceKey] = instance.GetInternalClone();
|
||||
|
||||
var extensions = GetFieldValue<Extension[]?>(Models.Metadata.Device.ExtensionKey);
|
||||
if (extensions != null)
|
||||
{
|
||||
Models.Metadata.Extension[] extensionItems = Array.ConvertAll(extensions, extension => extension.GetInternalClone());
|
||||
deviceItem[Models.Metadata.Device.ExtensionKey] = extensionItems;
|
||||
}
|
||||
|
||||
return deviceItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DeviceRef() : base() { }
|
||||
|
||||
public DeviceRef(Models.Metadata.DeviceRef item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DipLocation() : base() { }
|
||||
|
||||
public DipLocation(Models.Metadata.DipLocation item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DipSwitch() : base() { }
|
||||
|
||||
public DipSwitch(Models.Metadata.DipSwitch item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -103,5 +104,35 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.DipSwitch GetInternalClone()
|
||||
{
|
||||
var dipSwitchItem = base.GetInternalClone();
|
||||
|
||||
var condition = GetFieldValue<Condition?>(Models.Metadata.DipSwitch.ConditionKey);
|
||||
if (condition != null)
|
||||
dipSwitchItem[Models.Metadata.DipSwitch.ConditionKey] = condition.GetInternalClone();
|
||||
|
||||
var dipLocations = GetFieldValue<DipLocation[]?>(Models.Metadata.DipSwitch.DipLocationKey);
|
||||
if (dipLocations != null)
|
||||
{
|
||||
Models.Metadata.DipLocation[] dipLocationItems = Array.ConvertAll(dipLocations, dipLocation => dipLocation.GetInternalClone());
|
||||
dipSwitchItem[Models.Metadata.DipSwitch.DipLocationKey] = dipLocationItems;
|
||||
}
|
||||
|
||||
var dipValues = GetFieldValue<DipValue[]?>(Models.Metadata.DipSwitch.DipValueKey);
|
||||
if (dipValues != null)
|
||||
{
|
||||
Models.Metadata.DipValue[] dipValueItems = Array.ConvertAll(dipValues, dipValue => dipValue.GetInternalClone());
|
||||
dipSwitchItem[Models.Metadata.DipSwitch.DipValueKey] = dipValueItems;
|
||||
}
|
||||
|
||||
return dipSwitchItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DipValue() : base() { }
|
||||
|
||||
public DipValue(Models.Metadata.DipValue item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -46,5 +47,22 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.DipValue GetInternalClone()
|
||||
{
|
||||
var dipValueItem = base.GetInternalClone();
|
||||
|
||||
// Handle subitems
|
||||
var subCondition = GetFieldValue<Condition>(Models.Metadata.DipValue.ConditionKey);
|
||||
if (subCondition != null)
|
||||
dipValueItem[Models.Metadata.DipValue.ConditionKey] = subCondition.GetInternalClone();
|
||||
|
||||
return dipValueItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public DiskArea() : base() { }
|
||||
|
||||
public DiskArea(Models.Metadata.DiskArea item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Display() : base() { }
|
||||
|
||||
public Display(Models.Metadata.Display item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Driver() : base() { }
|
||||
|
||||
public Driver(Models.Metadata.Driver item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Extension() : base() { }
|
||||
|
||||
public Extension(Models.Metadata.Extension item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Feature() : base() { }
|
||||
|
||||
public Feature(Models.Metadata.Feature item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Info() : base() { }
|
||||
|
||||
public Info(Models.Metadata.Info item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Input() : base() { }
|
||||
|
||||
public Input(Models.Metadata.Input item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
@@ -59,5 +60,24 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Input GetInternalClone()
|
||||
{
|
||||
var inputItem = base.GetInternalClone();
|
||||
|
||||
var controls = GetFieldValue<Control[]?>(Models.Metadata.Input.ControlKey);
|
||||
if (controls != null)
|
||||
{
|
||||
Models.Metadata.Control[] controlItems = Array.ConvertAll(controls, control => control.GetInternalClone());
|
||||
inputItem[Models.Metadata.Input.ControlKey] = controlItems;
|
||||
}
|
||||
|
||||
return inputItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Instance() : base() { }
|
||||
|
||||
public Instance(Models.Metadata.Instance item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Part() : base() { }
|
||||
|
||||
public Part(Models.Metadata.Part item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public PartFeature() : base() { }
|
||||
|
||||
public PartFeature(Models.Metadata.Feature item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Port() : base() { }
|
||||
|
||||
public Port(Models.Metadata.Port item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
@@ -46,5 +47,24 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Port GetInternalClone()
|
||||
{
|
||||
var portItem = base.GetInternalClone();
|
||||
|
||||
var analogs = GetFieldValue<Analog[]?>(Models.Metadata.Port.AnalogKey);
|
||||
if (analogs != null)
|
||||
{
|
||||
Models.Metadata.Analog[] analogItems = Array.ConvertAll(analogs, analog => analog.GetInternalClone());
|
||||
portItem[Models.Metadata.Port.AnalogKey] = analogItems;
|
||||
}
|
||||
|
||||
return portItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public RamOption() : base() { }
|
||||
|
||||
public RamOption(Models.Metadata.RamOption item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Release() : base() { }
|
||||
|
||||
public Release(Models.Metadata.Release item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
|
||||
// TODO: Add item mappings for all fields
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Sample() : base() { }
|
||||
|
||||
public Sample(Models.Metadata.Sample item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public SharedFeat() : base() { }
|
||||
|
||||
public SharedFeat(Models.Metadata.SharedFeat item) : base(item) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Slot() : base() { }
|
||||
|
||||
public Slot(Models.Metadata.Slot item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
@@ -46,5 +47,24 @@ namespace SabreTools.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Models.Metadata.Slot GetInternalClone()
|
||||
{
|
||||
var slotItem = base.GetInternalClone();
|
||||
|
||||
var slotOptions = GetFieldValue<SlotOption[]?>(Models.Metadata.Slot.SlotOptionKey);
|
||||
if (slotOptions != null)
|
||||
{
|
||||
Models.Metadata.SlotOption[] slotOptionItems = Array.ConvertAll(slotOptions, slotOption => slotOption.GetInternalClone());
|
||||
slotItem[Models.Metadata.Slot.SlotOptionKey] = slotOptionItems;
|
||||
}
|
||||
|
||||
return slotItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public SlotOption() : base() { }
|
||||
|
||||
public SlotOption(Models.Metadata.SlotOption item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
@@ -23,12 +23,13 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public SoftwareList() : base() { }
|
||||
|
||||
public SoftwareList(Models.Metadata.SoftwareList item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
if (GetStringFieldValue(Models.Metadata.SoftwareList.StatusKey) != null)
|
||||
SetFieldValue<string?>(Models.Metadata.SoftwareList.StatusKey, GetStringFieldValue(Models.Metadata.SoftwareList.StatusKey).AsEnumValue<SoftwareListStatus>().AsStringValue());
|
||||
|
||||
|
||||
// Handle subitems
|
||||
// TODO: Handle the Software subitem
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SabreTools.DatItems.Formats
|
||||
#region Constructors
|
||||
|
||||
public Sound() : base() { }
|
||||
|
||||
public Sound(Models.Metadata.Sound item) : base(item)
|
||||
{
|
||||
// Process flag values
|
||||
|
||||
Reference in New Issue
Block a user