mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-21 22:35:06 +00:00
Flatten Condition out of existence
This commit is contained in:
@@ -17,7 +17,6 @@ namespace SabreTools.Metadata.DatItems
|
||||
[XmlInclude(typeof(BiosSet))]
|
||||
[XmlInclude(typeof(Blank))]
|
||||
[XmlInclude(typeof(Chip))]
|
||||
[XmlInclude(typeof(Condition))]
|
||||
[XmlInclude(typeof(Configuration))]
|
||||
[XmlInclude(typeof(ConfLocation))]
|
||||
[XmlInclude(typeof(ConfSetting))]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Metadata.Filter;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -12,10 +11,29 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
public string? ConditionMask
|
||||
{
|
||||
get => _internal.ConditionMask;
|
||||
set => _internal.ConditionMask = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionSpecified => Condition is not null;
|
||||
public Data.Models.Metadata.Relation? ConditionRelation
|
||||
{
|
||||
get => _internal.ConditionRelation;
|
||||
set => _internal.ConditionRelation = value;
|
||||
}
|
||||
|
||||
public string? ConditionTag
|
||||
{
|
||||
get => _internal.ConditionTag;
|
||||
set => _internal.ConditionTag = value;
|
||||
}
|
||||
|
||||
public string? ConditionValue
|
||||
{
|
||||
get => _internal.ConditionValue;
|
||||
set => _internal.ConditionValue = value;
|
||||
}
|
||||
|
||||
public bool? Default
|
||||
{
|
||||
@@ -39,12 +57,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
public Adjuster() : base() { }
|
||||
|
||||
public Adjuster(Data.Models.Metadata.Adjuster item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
if (item.Condition is not null)
|
||||
Condition = new Condition(item.Condition);
|
||||
}
|
||||
public Adjuster(Data.Models.Metadata.Adjuster item) : base(item) { }
|
||||
|
||||
public Adjuster(Data.Models.Metadata.Adjuster item, Machine machine, Source source) : this(item)
|
||||
{
|
||||
@@ -71,14 +84,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Data.Models.Metadata.Adjuster GetInternalClone()
|
||||
{
|
||||
var adjusterItem = _internal.Clone() as Data.Models.Metadata.Adjuster ?? new();
|
||||
|
||||
if (Condition is not null)
|
||||
adjusterItem.Condition = Condition.GetInternalClone();
|
||||
|
||||
return adjusterItem;
|
||||
}
|
||||
=>_internal.Clone() as Data.Models.Metadata.Adjuster ?? new();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -100,28 +106,5 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(FilterRunner filterRunner)
|
||||
{
|
||||
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
||||
return false;
|
||||
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilterDB(FilterRunner filterRunner)
|
||||
{
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a condition on a machine or other item
|
||||
/// </summary>
|
||||
[JsonObject("condition"), XmlRoot("condition")]
|
||||
public sealed class Condition : DatItem<Data.Models.Metadata.Condition>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <inheritdoc>/>
|
||||
public override Data.Models.Metadata.ItemType ItemType
|
||||
=> Data.Models.Metadata.ItemType.Condition;
|
||||
|
||||
public string? Mask
|
||||
{
|
||||
get => _internal.Mask;
|
||||
set => _internal.Mask = value;
|
||||
}
|
||||
|
||||
public Data.Models.Metadata.Relation? Relation
|
||||
{
|
||||
get => _internal.Relation;
|
||||
set => _internal.Relation = value;
|
||||
}
|
||||
|
||||
public string? Tag
|
||||
{
|
||||
get => _internal.Tag;
|
||||
set => _internal.Tag = value;
|
||||
}
|
||||
|
||||
public string? Value
|
||||
{
|
||||
get => _internal.Value;
|
||||
set => _internal.Value = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Condition() : base() { }
|
||||
|
||||
public Condition(Data.Models.Metadata.Condition item) : base(item) { }
|
||||
|
||||
public Condition(Data.Models.Metadata.Condition item, Machine machine, Source source) : this(item)
|
||||
{
|
||||
Source = source;
|
||||
CopyMachineInformation(machine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string? GetName() => null;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string? name) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object Clone() => new Condition(GetInternalClone());
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Data.Models.Metadata.Condition GetInternalClone()
|
||||
=> _internal.Clone() as Data.Models.Metadata.Condition ?? new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(DatItem? other)
|
||||
{
|
||||
// If the other item is null
|
||||
if (other is null)
|
||||
return false;
|
||||
|
||||
// If the type matches
|
||||
if (other is Condition otherCondition)
|
||||
return _internal.Equals(otherCondition._internal);
|
||||
|
||||
// Everything else fails
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Metadata.Filter;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -12,10 +11,29 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
public string? ConditionMask
|
||||
{
|
||||
get => _internal.ConditionMask;
|
||||
set => _internal.ConditionMask = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionSpecified => Condition is not null;
|
||||
public Data.Models.Metadata.Relation? ConditionRelation
|
||||
{
|
||||
get => _internal.ConditionRelation;
|
||||
set => _internal.ConditionRelation = value;
|
||||
}
|
||||
|
||||
public string? ConditionTag
|
||||
{
|
||||
get => _internal.ConditionTag;
|
||||
set => _internal.ConditionTag = value;
|
||||
}
|
||||
|
||||
public string? ConditionValue
|
||||
{
|
||||
get => _internal.ConditionValue;
|
||||
set => _internal.ConditionValue = value;
|
||||
}
|
||||
|
||||
public bool? Default
|
||||
{
|
||||
@@ -45,12 +63,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
public ConfSetting() : base() { }
|
||||
|
||||
public ConfSetting(Data.Models.Metadata.ConfSetting item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
if (item.Condition is not null)
|
||||
Condition = new Condition(item.Condition);
|
||||
}
|
||||
public ConfSetting(Data.Models.Metadata.ConfSetting item) : base(item) { }
|
||||
|
||||
public ConfSetting(Data.Models.Metadata.ConfSetting item, Machine machine, Source source) : this(item)
|
||||
{
|
||||
@@ -77,14 +90,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Data.Models.Metadata.ConfSetting GetInternalClone()
|
||||
{
|
||||
var confSettingItem = _internal.Clone() as Data.Models.Metadata.ConfSetting ?? new();
|
||||
|
||||
if (Condition is not null)
|
||||
confSettingItem.Condition = Condition.GetInternalClone();
|
||||
|
||||
return confSettingItem;
|
||||
}
|
||||
=> _internal.Clone() as Data.Models.Metadata.ConfSetting ?? new();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -106,28 +112,5 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(FilterRunner filterRunner)
|
||||
{
|
||||
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
||||
return false;
|
||||
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilterDB(FilterRunner filterRunner)
|
||||
{
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,29 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
public string? ConditionMask
|
||||
{
|
||||
get => _internal.ConditionMask;
|
||||
set => _internal.ConditionMask = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionSpecified => Condition is not null;
|
||||
public Data.Models.Metadata.Relation? ConditionRelation
|
||||
{
|
||||
get => _internal.ConditionRelation;
|
||||
set => _internal.ConditionRelation = value;
|
||||
}
|
||||
|
||||
public string? ConditionTag
|
||||
{
|
||||
get => _internal.ConditionTag;
|
||||
set => _internal.ConditionTag = value;
|
||||
}
|
||||
|
||||
public string? ConditionValue
|
||||
{
|
||||
get => _internal.ConditionValue;
|
||||
set => _internal.ConditionValue = value;
|
||||
}
|
||||
|
||||
public ConfLocation[]? ConfLocation { get; set; }
|
||||
|
||||
@@ -59,9 +78,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
public Configuration(Data.Models.Metadata.Configuration item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
if (item.Condition is not null)
|
||||
Condition = new Condition(item.Condition);
|
||||
|
||||
if (item.ConfLocation is not null)
|
||||
ConfLocation = Array.ConvertAll(item.ConfLocation, confLocation => new ConfLocation(confLocation));
|
||||
|
||||
@@ -97,9 +113,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
var configurationItem = _internal.Clone() as Data.Models.Metadata.Configuration ?? new();
|
||||
|
||||
if (Condition is not null)
|
||||
configurationItem.Condition = Condition.GetInternalClone();
|
||||
|
||||
if (ConfLocation is not null)
|
||||
configurationItem.ConfLocation = Array.ConvertAll(ConfLocation, confLocation => confLocation.GetInternalClone());
|
||||
|
||||
@@ -138,7 +151,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
||||
return false;
|
||||
|
||||
// TODO: Condition
|
||||
// TODO: ConfLocation
|
||||
// TODO: ConfSetting
|
||||
|
||||
@@ -148,7 +160,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilterDB(FilterRunner filterRunner)
|
||||
{
|
||||
// TODO: Condition
|
||||
// TODO: ConfLocation
|
||||
// TODO: ConfSetting
|
||||
|
||||
|
||||
@@ -13,10 +13,29 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
public string? ConditionMask
|
||||
{
|
||||
get => _internal.ConditionMask;
|
||||
set => _internal.ConditionMask = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionSpecified => Condition is not null;
|
||||
public Data.Models.Metadata.Relation? ConditionRelation
|
||||
{
|
||||
get => _internal.ConditionRelation;
|
||||
set => _internal.ConditionRelation = value;
|
||||
}
|
||||
|
||||
public string? ConditionTag
|
||||
{
|
||||
get => _internal.ConditionTag;
|
||||
set => _internal.ConditionTag = value;
|
||||
}
|
||||
|
||||
public string? ConditionValue
|
||||
{
|
||||
get => _internal.ConditionValue;
|
||||
set => _internal.ConditionValue = value;
|
||||
}
|
||||
|
||||
public bool? Default
|
||||
{
|
||||
@@ -83,9 +102,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
public DipSwitch(Data.Models.Metadata.DipSwitch item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
if (item.Condition is not null)
|
||||
Condition = new Condition(item.Condition);
|
||||
|
||||
if (item.DipLocation is not null)
|
||||
DipLocation = Array.ConvertAll(item.DipLocation, dipLocation => new DipLocation(dipLocation));
|
||||
|
||||
@@ -124,9 +140,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
var dipSwitchItem = _internal.Clone() as Data.Models.Metadata.DipSwitch ?? new();
|
||||
|
||||
if (Condition is not null)
|
||||
dipSwitchItem.Condition = Condition.GetInternalClone();
|
||||
|
||||
if (DipLocation is not null)
|
||||
dipSwitchItem.DipLocation = Array.ConvertAll(DipLocation, dipLocation => dipLocation.GetInternalClone());
|
||||
|
||||
@@ -168,7 +181,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
||||
return false;
|
||||
|
||||
// TODO: Condition
|
||||
// TODO: DipLocation
|
||||
// TODO: DipValue
|
||||
// TODO: Entry
|
||||
@@ -179,7 +191,6 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilterDB(FilterRunner filterRunner)
|
||||
{
|
||||
// TODO: Condition
|
||||
// TODO: DipLocation
|
||||
// TODO: DipValue
|
||||
// TODO: Entry
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Metadata.Filter;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -12,10 +11,29 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
public string? ConditionMask
|
||||
{
|
||||
get => _internal.ConditionMask;
|
||||
set => _internal.ConditionMask = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionSpecified => Condition is not null;
|
||||
public Data.Models.Metadata.Relation? ConditionRelation
|
||||
{
|
||||
get => _internal.ConditionRelation;
|
||||
set => _internal.ConditionRelation = value;
|
||||
}
|
||||
|
||||
public string? ConditionTag
|
||||
{
|
||||
get => _internal.ConditionTag;
|
||||
set => _internal.ConditionTag = value;
|
||||
}
|
||||
|
||||
public string? ConditionValue
|
||||
{
|
||||
get => _internal.ConditionValue;
|
||||
set => _internal.ConditionValue = value;
|
||||
}
|
||||
|
||||
public bool? Default
|
||||
{
|
||||
@@ -45,12 +63,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
public DipValue() : base() { }
|
||||
|
||||
public DipValue(Data.Models.Metadata.DipValue item) : base(item)
|
||||
{
|
||||
// Handle subitems
|
||||
if (item.Condition is not null)
|
||||
Condition = new Condition(item.Condition);
|
||||
}
|
||||
public DipValue(Data.Models.Metadata.DipValue item) : base(item) { }
|
||||
|
||||
public DipValue(Data.Models.Metadata.DipValue item, Machine machine, Source source) : this(item)
|
||||
{
|
||||
@@ -77,14 +90,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Data.Models.Metadata.DipValue GetInternalClone()
|
||||
{
|
||||
var dipValueItem = _internal.Clone() as Data.Models.Metadata.DipValue ?? new();
|
||||
|
||||
if (Condition is not null)
|
||||
dipValueItem.Condition = Condition.GetInternalClone();
|
||||
|
||||
return dipValueItem;
|
||||
}
|
||||
=> _internal.Clone() as Data.Models.Metadata.DipValue ?? new();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -106,28 +112,5 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(FilterRunner filterRunner)
|
||||
{
|
||||
if (Machine is not null && !Machine.PassesFilter(filterRunner))
|
||||
return false;
|
||||
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilterDB(FilterRunner filterRunner)
|
||||
{
|
||||
// TODO: Condition
|
||||
|
||||
return filterRunner.Run(_internal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user