mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-09 02:16:55 +00:00
Flatten Condition out of existence
This commit is contained in:
@@ -2743,7 +2743,6 @@ namespace SabreTools.Data.Extensions.Test
|
||||
[InlineData("biosset", ItemType.BiosSet)]
|
||||
[InlineData("blank", ItemType.Blank)]
|
||||
[InlineData("chip", ItemType.Chip)]
|
||||
[InlineData("condition", ItemType.Condition)]
|
||||
[InlineData("configuration", ItemType.Configuration)]
|
||||
[InlineData("conflocation", ItemType.ConfLocation)]
|
||||
[InlineData("confsetting", ItemType.ConfSetting)]
|
||||
@@ -3146,7 +3145,6 @@ namespace SabreTools.Data.Extensions.Test
|
||||
[InlineData(ItemType.BiosSet, "biosset")]
|
||||
[InlineData(ItemType.Blank, "blank")]
|
||||
[InlineData(ItemType.Chip, "chip")]
|
||||
[InlineData(ItemType.Condition, "condition")]
|
||||
[InlineData(ItemType.Configuration, "configuration")]
|
||||
[InlineData(ItemType.ConfLocation, "conflocation")]
|
||||
[InlineData(ItemType.ConfSetting, "confsetting")]
|
||||
|
||||
@@ -909,7 +909,6 @@ namespace SabreTools.Data.Extensions
|
||||
"archive" => ItemType.Archive,
|
||||
"biosset" => ItemType.BiosSet,
|
||||
"chip" => ItemType.Chip,
|
||||
"condition" => ItemType.Condition,
|
||||
"configuration" => ItemType.Configuration,
|
||||
"conflocation" => ItemType.ConfLocation,
|
||||
"confsetting" => ItemType.ConfSetting,
|
||||
@@ -1393,7 +1392,6 @@ namespace SabreTools.Data.Extensions
|
||||
ItemType.Archive => "archive",
|
||||
ItemType.BiosSet => "biosset",
|
||||
ItemType.Chip => "chip",
|
||||
ItemType.Condition => "condition",
|
||||
ItemType.Configuration => "configuration",
|
||||
ItemType.ConfLocation => "conflocation",
|
||||
ItemType.ConfSetting => "confsetting",
|
||||
|
||||
@@ -9,7 +9,17 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionMask { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? ConditionRelation { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionTag { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionValue { get; set; }
|
||||
|
||||
/// <remarks>(yes|no) "no"</remarks>
|
||||
public bool? Default { get; set; }
|
||||
@@ -25,7 +35,10 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
var obj = new Adjuster();
|
||||
|
||||
obj.Condition = Condition?.Clone() as Condition;
|
||||
obj.ConditionMask = ConditionMask;
|
||||
obj.ConditionRelation = ConditionRelation;
|
||||
obj.ConditionTag = ConditionTag;
|
||||
obj.ConditionValue = ConditionValue;
|
||||
obj.Default = Default;
|
||||
obj.Name = Name;
|
||||
|
||||
@@ -40,6 +53,24 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((ConditionMask is null) ^ (other.ConditionMask is null))
|
||||
return false;
|
||||
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (ConditionRelation != other.ConditionRelation)
|
||||
return false;
|
||||
|
||||
if ((ConditionTag is null) ^ (other.ConditionTag is null))
|
||||
return false;
|
||||
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((ConditionValue is null) ^ (other.ConditionValue is null))
|
||||
return false;
|
||||
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (Default != other.Default)
|
||||
return false;
|
||||
|
||||
@@ -48,12 +79,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
// Sub-items
|
||||
if ((Condition is null) ^ (other.Condition is null))
|
||||
return false;
|
||||
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
[JsonObject("condition"), XmlRoot("condition")]
|
||||
public class Condition : DatItem, ICloneable, IEquatable<Condition>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public string? Mask { get; set; }
|
||||
|
||||
/// <remarks>(eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? Relation { get; set; }
|
||||
|
||||
public string? Tag { get; set; }
|
||||
|
||||
public string? Value { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public Condition() => ItemType = ItemType.Condition;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object Clone()
|
||||
{
|
||||
var obj = new Condition();
|
||||
|
||||
obj.Mask = Mask;
|
||||
obj.Relation = Relation;
|
||||
obj.Tag = Tag;
|
||||
obj.Value = Value;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Condition? other)
|
||||
{
|
||||
// Null never matches
|
||||
if (other is null)
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((Mask is null) ^ (other.Mask is null))
|
||||
return false;
|
||||
else if (Mask is not null && !Mask.Equals(other.Mask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (Relation != other.Relation)
|
||||
return false;
|
||||
|
||||
if ((Tag is null) ^ (other.Tag is null))
|
||||
return false;
|
||||
else if (Tag is not null && !Tag.Equals(other.Tag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((Value is null) ^ (other.Value is null))
|
||||
return false;
|
||||
else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,17 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionMask { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? ConditionRelation { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionTag { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionValue { get; set; }
|
||||
|
||||
/// <remarks>(yes|no) "no"</remarks>
|
||||
public bool? Default { get; set; }
|
||||
@@ -27,7 +37,10 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
var obj = new ConfSetting();
|
||||
|
||||
obj.Condition = Condition?.Clone() as Condition;
|
||||
obj.ConditionMask = ConditionMask;
|
||||
obj.ConditionRelation = ConditionRelation;
|
||||
obj.ConditionTag = ConditionTag;
|
||||
obj.ConditionValue = ConditionValue;
|
||||
obj.Default = Default;
|
||||
obj.Name = Name;
|
||||
obj.Value = Value;
|
||||
@@ -43,6 +56,24 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((ConditionMask is null) ^ (other.ConditionMask is null))
|
||||
return false;
|
||||
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (ConditionRelation != other.ConditionRelation)
|
||||
return false;
|
||||
|
||||
if ((ConditionTag is null) ^ (other.ConditionTag is null))
|
||||
return false;
|
||||
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((ConditionValue is null) ^ (other.ConditionValue is null))
|
||||
return false;
|
||||
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (Default != other.Default)
|
||||
return false;
|
||||
|
||||
@@ -56,12 +87,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
// Sub-items
|
||||
if ((Condition is null) ^ (other.Condition is null))
|
||||
return false;
|
||||
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,17 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionMask { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? ConditionRelation { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionTag { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionValue { get; set; }
|
||||
|
||||
public ConfLocation[]? ConfLocation { get; set; }
|
||||
|
||||
@@ -30,7 +40,10 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
var obj = new Configuration();
|
||||
|
||||
obj.Condition = Condition?.Clone() as Condition;
|
||||
obj.ConditionMask = ConditionMask;
|
||||
obj.ConditionRelation = ConditionRelation;
|
||||
obj.ConditionTag = ConditionTag;
|
||||
obj.ConditionValue = ConditionValue;
|
||||
if (ConfLocation is not null)
|
||||
obj.ConfLocation = Array.ConvertAll(ConfLocation, i => (ConfLocation)i.Clone());
|
||||
if (ConfSetting is not null)
|
||||
@@ -50,6 +63,24 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((ConditionMask is null) ^ (other.ConditionMask is null))
|
||||
return false;
|
||||
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (ConditionRelation != other.ConditionRelation)
|
||||
return false;
|
||||
|
||||
if ((ConditionTag is null) ^ (other.ConditionTag is null))
|
||||
return false;
|
||||
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((ConditionValue is null) ^ (other.ConditionValue is null))
|
||||
return false;
|
||||
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((Mask is null) ^ (other.Mask is null))
|
||||
return false;
|
||||
else if (Mask is not null && !Mask.Equals(other.Mask, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -65,12 +96,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
else if (Tag is not null && !Tag.Equals(other.Tag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
// Sub-items
|
||||
if ((Condition is null) ^ (other.Condition is null))
|
||||
return false;
|
||||
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
|
||||
return false;
|
||||
|
||||
// TODO: Figure out how to properly check arrays
|
||||
|
||||
return true;
|
||||
|
||||
@@ -9,7 +9,17 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionMask { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? ConditionRelation { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionTag { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionValue { get; set; }
|
||||
|
||||
/// <remarks>(yes|no) "no"</remarks>
|
||||
public bool? Default { get; set; }
|
||||
@@ -35,7 +45,10 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
var obj = new DipSwitch();
|
||||
|
||||
obj.Condition = Condition?.Clone() as Condition;
|
||||
obj.ConditionMask = ConditionMask;
|
||||
obj.ConditionRelation = ConditionRelation;
|
||||
obj.ConditionTag = ConditionTag;
|
||||
obj.ConditionValue = ConditionValue;
|
||||
obj.Default = Default;
|
||||
if (DipLocation is not null)
|
||||
obj.DipLocation = Array.ConvertAll(DipLocation, i => (DipLocation)i.Clone());
|
||||
@@ -58,6 +71,24 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((ConditionMask is null) ^ (other.ConditionMask is null))
|
||||
return false;
|
||||
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (ConditionRelation != other.ConditionRelation)
|
||||
return false;
|
||||
|
||||
if ((ConditionTag is null) ^ (other.ConditionTag is null))
|
||||
return false;
|
||||
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((ConditionValue is null) ^ (other.ConditionValue is null))
|
||||
return false;
|
||||
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((Mask is null) ^ (other.Mask is null))
|
||||
return false;
|
||||
else if (Mask is not null && !Mask.Equals(other.Mask, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -73,12 +104,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
else if (Tag is not null && !Tag.Equals(other.Tag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
// Sub-items
|
||||
if ((Condition is null) ^ (other.Condition is null))
|
||||
return false;
|
||||
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
|
||||
return false;
|
||||
|
||||
// TODO: Figure out how to properly check arrays
|
||||
|
||||
return true;
|
||||
|
||||
@@ -9,7 +9,17 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public Condition? Condition { get; set; }
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionMask { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem, (eq|ne|gt|le|lt|ge)</remarks>
|
||||
public Relation? ConditionRelation { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionTag { get; set; }
|
||||
|
||||
/// <remarks>Condition subitem</remarks>
|
||||
public string? ConditionValue { get; set; }
|
||||
|
||||
/// <remarks>(yes|no) "no"</remarks>
|
||||
public bool? Default { get; set; }
|
||||
@@ -27,7 +37,10 @@ namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
var obj = new DipValue();
|
||||
|
||||
obj.Condition = Condition?.Clone() as Condition;
|
||||
obj.ConditionMask = ConditionMask;
|
||||
obj.ConditionRelation = ConditionRelation;
|
||||
obj.ConditionTag = ConditionTag;
|
||||
obj.ConditionValue = ConditionValue;
|
||||
obj.Default = Default;
|
||||
obj.Name = Name;
|
||||
obj.Value = Value;
|
||||
@@ -43,6 +56,24 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((ConditionMask is null) ^ (other.ConditionMask is null))
|
||||
return false;
|
||||
else if (ConditionMask is not null && !ConditionMask.Equals(other.ConditionMask, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (ConditionRelation != other.ConditionRelation)
|
||||
return false;
|
||||
|
||||
if ((ConditionTag is null) ^ (other.ConditionTag is null))
|
||||
return false;
|
||||
else if (ConditionTag is not null && !ConditionTag.Equals(other.ConditionTag, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if ((ConditionValue is null) ^ (other.ConditionValue is null))
|
||||
return false;
|
||||
else if (ConditionValue is not null && !ConditionValue.Equals(other.ConditionValue, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (Default != other.Default)
|
||||
return false;
|
||||
|
||||
@@ -56,12 +87,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
// Sub-items
|
||||
if ((Condition is null) ^ (other.Condition is null))
|
||||
return false;
|
||||
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,6 @@ namespace SabreTools.Data.Models.Metadata
|
||||
Archive,
|
||||
BiosSet,
|
||||
Chip,
|
||||
Condition,
|
||||
Configuration,
|
||||
ConfLocation,
|
||||
ConfSetting,
|
||||
|
||||
@@ -346,7 +346,10 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
return new Data.Models.Metadata.Adjuster
|
||||
{
|
||||
Condition = CreateMetadataCondition(),
|
||||
ConditionValue = "value",
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Data.Models.Metadata.Relation.Equal,
|
||||
ConditionTag = "tag",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
};
|
||||
@@ -427,7 +430,10 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
return new Data.Models.Metadata.Configuration
|
||||
{
|
||||
Condition = CreateMetadataCondition(),
|
||||
ConditionValue = "value",
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Data.Models.Metadata.Relation.Equal,
|
||||
ConditionTag = "tag",
|
||||
ConfLocation = [CreateMetadataConfLocation()],
|
||||
ConfSetting = [CreateMetadataConfSetting()],
|
||||
Mask = "mask",
|
||||
@@ -436,17 +442,6 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
};
|
||||
}
|
||||
|
||||
private static Data.Models.Metadata.Condition CreateMetadataCondition()
|
||||
{
|
||||
return new Data.Models.Metadata.Condition
|
||||
{
|
||||
Value = "value",
|
||||
Mask = "mask",
|
||||
Relation = Data.Models.Metadata.Relation.Equal,
|
||||
Tag = "tag",
|
||||
};
|
||||
}
|
||||
|
||||
private static Data.Models.Metadata.ConfLocation CreateMetadataConfLocation()
|
||||
{
|
||||
return new Data.Models.Metadata.ConfLocation
|
||||
@@ -461,7 +456,10 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
return new Data.Models.Metadata.ConfSetting
|
||||
{
|
||||
Condition = CreateMetadataCondition(),
|
||||
ConditionValue = "value",
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Data.Models.Metadata.Relation.Equal,
|
||||
ConditionTag = "tag",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
Value = "value",
|
||||
@@ -523,7 +521,10 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
return new Data.Models.Metadata.DipSwitch
|
||||
{
|
||||
Condition = CreateMetadataCondition(),
|
||||
ConditionValue = "value",
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Data.Models.Metadata.Relation.Equal,
|
||||
ConditionTag = "tag",
|
||||
Default = true,
|
||||
DipLocation = [CreateMetadataDipLocation()],
|
||||
DipValue = [CreateMetadataDipValue()],
|
||||
@@ -538,7 +539,10 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
return new Data.Models.Metadata.DipValue
|
||||
{
|
||||
Condition = CreateMetadataCondition(),
|
||||
ConditionValue = "value",
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Data.Models.Metadata.Relation.Equal,
|
||||
ConditionTag = "tag",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
Value = "value",
|
||||
@@ -1132,10 +1136,12 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateAdjuster(Adjuster? adjuster)
|
||||
{
|
||||
Assert.NotNull(adjuster);
|
||||
Assert.Equal("value", adjuster.ConditionValue);
|
||||
Assert.Equal("mask", adjuster.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, adjuster.ConditionRelation);
|
||||
Assert.Equal("tag", adjuster.ConditionTag);
|
||||
Assert.True(adjuster.Default);
|
||||
Assert.Equal("name", adjuster.Name);
|
||||
|
||||
ValidateCondition(adjuster.Condition);
|
||||
}
|
||||
|
||||
private static void ValidateAnalog(Analog? analog)
|
||||
@@ -1169,24 +1175,17 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
Assert.Equal(Data.Models.Metadata.ChipType.CPU, chip.ChipType);
|
||||
}
|
||||
|
||||
private static void ValidateCondition(Condition? condition)
|
||||
{
|
||||
Assert.NotNull(condition);
|
||||
Assert.Equal("value", condition.Value);
|
||||
Assert.Equal("mask", condition.Mask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, condition.Relation);
|
||||
Assert.Equal("tag", condition.Tag);
|
||||
}
|
||||
|
||||
private static void ValidateConfiguration(Configuration? configuration)
|
||||
{
|
||||
Assert.NotNull(configuration);
|
||||
Assert.Equal("value", configuration.ConditionValue);
|
||||
Assert.Equal("mask", configuration.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, configuration.ConditionRelation);
|
||||
Assert.Equal("tag", configuration.ConditionTag);
|
||||
Assert.Equal("mask", configuration.Mask);
|
||||
Assert.Equal("name", configuration.Name);
|
||||
Assert.Equal("tag", configuration.Tag);
|
||||
|
||||
ValidateCondition(configuration.Condition);
|
||||
|
||||
ConfLocation[]? confLocations = configuration.ConfLocation;
|
||||
Assert.NotNull(confLocations);
|
||||
ConfLocation? confLocation = Assert.Single(confLocations);
|
||||
@@ -1209,11 +1208,13 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateConfSetting(ConfSetting? confSetting)
|
||||
{
|
||||
Assert.NotNull(confSetting);
|
||||
Assert.Equal("value", confSetting.ConditionValue);
|
||||
Assert.Equal("mask", confSetting.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, confSetting.ConditionRelation);
|
||||
Assert.Equal("tag", confSetting.ConditionTag);
|
||||
Assert.True(confSetting.Default);
|
||||
Assert.Equal("name", confSetting.Name);
|
||||
Assert.Equal("value", confSetting.Value);
|
||||
|
||||
ValidateCondition(confSetting.Condition);
|
||||
}
|
||||
|
||||
private static void ValidateControl(Control? control)
|
||||
@@ -1276,13 +1277,15 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateDipSwitch(DipSwitch? dipSwitch)
|
||||
{
|
||||
Assert.NotNull(dipSwitch);
|
||||
Assert.Equal("value", dipSwitch.ConditionValue);
|
||||
Assert.Equal("mask", dipSwitch.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, dipSwitch.ConditionRelation);
|
||||
Assert.Equal("tag", dipSwitch.ConditionTag);
|
||||
Assert.True(dipSwitch.Default);
|
||||
Assert.Equal("mask", dipSwitch.Mask);
|
||||
Assert.Equal("name", dipSwitch.Name);
|
||||
Assert.Equal("tag", dipSwitch.Tag);
|
||||
|
||||
ValidateCondition(dipSwitch.Condition);
|
||||
|
||||
DipLocation[]? dipLocations = dipSwitch.DipLocation;
|
||||
Assert.NotNull(dipLocations);
|
||||
DipLocation? dipLocation = Assert.Single(dipLocations);
|
||||
@@ -1302,11 +1305,13 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateDipValue(DipValue? dipValue)
|
||||
{
|
||||
Assert.NotNull(dipValue);
|
||||
Assert.Equal("value", dipValue.ConditionValue);
|
||||
Assert.Equal("mask", dipValue.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, dipValue.ConditionRelation);
|
||||
Assert.Equal("tag", dipValue.ConditionTag);
|
||||
Assert.True(dipValue.Default);
|
||||
Assert.Equal("name", dipValue.Name);
|
||||
Assert.Equal("value", dipValue.Value);
|
||||
|
||||
ValidateCondition(dipValue.Condition);
|
||||
}
|
||||
|
||||
private static void ValidateDisk(Disk? disk)
|
||||
|
||||
@@ -612,11 +612,12 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateMetadataAdjuster(Data.Models.Metadata.Adjuster? adjuster)
|
||||
{
|
||||
Assert.NotNull(adjuster);
|
||||
Assert.Equal("value", adjuster.ConditionValue);
|
||||
Assert.Equal("mask", adjuster.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, adjuster.ConditionRelation);
|
||||
Assert.Equal("tag", adjuster.ConditionTag);
|
||||
Assert.True(adjuster.Default);
|
||||
Assert.Equal("name", adjuster.Name);
|
||||
|
||||
Data.Models.Metadata.Condition? condition = adjuster.Condition;
|
||||
ValidateMetadataCondition(condition);
|
||||
}
|
||||
|
||||
private static void ValidateMetadataAnalog(Data.Models.Metadata.Analog? analog)
|
||||
@@ -682,24 +683,17 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
Assert.Equal(Data.Models.Metadata.ChipType.CPU, chip.ChipType);
|
||||
}
|
||||
|
||||
private static void ValidateMetadataCondition(Data.Models.Metadata.Condition? condition)
|
||||
{
|
||||
Assert.NotNull(condition);
|
||||
Assert.Equal("value", condition.Value);
|
||||
Assert.Equal("mask", condition.Mask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, condition.Relation);
|
||||
Assert.Equal("tag", condition.Tag);
|
||||
}
|
||||
|
||||
private static void ValidateMetadataConfiguration(Data.Models.Metadata.Configuration? configuration)
|
||||
{
|
||||
Assert.NotNull(configuration);
|
||||
Assert.Equal("value", configuration.ConditionValue);
|
||||
Assert.Equal("mask", configuration.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, configuration.ConditionRelation);
|
||||
Assert.Equal("tag", configuration.ConditionTag);
|
||||
Assert.Equal("mask", configuration.Mask);
|
||||
Assert.Equal("name", configuration.Name);
|
||||
Assert.Equal("tag", configuration.Tag);
|
||||
|
||||
ValidateMetadataCondition(configuration.Condition);
|
||||
|
||||
Data.Models.Metadata.ConfLocation[]? confLocations = configuration.ConfLocation;
|
||||
Assert.NotNull(confLocations);
|
||||
Data.Models.Metadata.ConfLocation? confLocation = Assert.Single(confLocations);
|
||||
@@ -722,11 +716,13 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateMetadataConfSetting(Data.Models.Metadata.ConfSetting? confSetting)
|
||||
{
|
||||
Assert.NotNull(confSetting);
|
||||
Assert.Equal("value", confSetting.ConditionValue);
|
||||
Assert.Equal("mask", confSetting.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, confSetting.ConditionRelation);
|
||||
Assert.Equal("tag", confSetting.ConditionTag);
|
||||
Assert.True(confSetting.Default);
|
||||
Assert.Equal("name", confSetting.Name);
|
||||
Assert.Equal("value", confSetting.Value);
|
||||
|
||||
ValidateMetadataCondition(confSetting.Condition);
|
||||
}
|
||||
|
||||
private static void ValidateMetadataControl(Data.Models.Metadata.Control? control)
|
||||
@@ -794,13 +790,15 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateMetadataDipSwitch(Data.Models.Metadata.DipSwitch? dipSwitch)
|
||||
{
|
||||
Assert.NotNull(dipSwitch);
|
||||
Assert.Equal("value", dipSwitch.ConditionValue);
|
||||
Assert.Equal("mask", dipSwitch.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, dipSwitch.ConditionRelation);
|
||||
Assert.Equal("tag", dipSwitch.ConditionTag);
|
||||
Assert.True(dipSwitch.Default);
|
||||
Assert.Equal("mask", dipSwitch.Mask);
|
||||
Assert.Equal("name", dipSwitch.Name);
|
||||
Assert.Equal("tag", dipSwitch.Tag);
|
||||
|
||||
ValidateMetadataCondition(dipSwitch.Condition);
|
||||
|
||||
Data.Models.Metadata.DipLocation[]? dipLocations = dipSwitch.DipLocation;
|
||||
Assert.NotNull(dipLocations);
|
||||
Data.Models.Metadata.DipLocation? dipLocation = Assert.Single(dipLocations);
|
||||
@@ -820,11 +818,13 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
private static void ValidateMetadataDipValue(Data.Models.Metadata.DipValue? dipValue)
|
||||
{
|
||||
Assert.NotNull(dipValue);
|
||||
Assert.Equal("value", dipValue.ConditionValue);
|
||||
Assert.Equal("mask", dipValue.ConditionMask);
|
||||
Assert.Equal(Data.Models.Metadata.Relation.Equal, dipValue.ConditionRelation);
|
||||
Assert.Equal("tag", dipValue.ConditionTag);
|
||||
Assert.True(dipValue.Default);
|
||||
Assert.Equal("name", dipValue.Name);
|
||||
Assert.Equal("value", dipValue.Value);
|
||||
|
||||
ValidateMetadataCondition(dipValue.Condition);
|
||||
}
|
||||
|
||||
private static void ValidateMetadataDisk(Data.Models.Metadata.Disk? disk)
|
||||
|
||||
@@ -760,7 +760,6 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
Data.Models.Metadata.ItemType.Adjuster,
|
||||
Data.Models.Metadata.ItemType.BiosSet,
|
||||
Data.Models.Metadata.ItemType.Chip,
|
||||
Data.Models.Metadata.ItemType.Condition,
|
||||
Data.Models.Metadata.ItemType.Configuration,
|
||||
Data.Models.Metadata.ItemType.Device,
|
||||
Data.Models.Metadata.ItemType.DeviceRef,
|
||||
|
||||
@@ -189,7 +189,6 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
Data.Models.Metadata.ItemType.Adjuster,
|
||||
Data.Models.Metadata.ItemType.BiosSet,
|
||||
Data.Models.Metadata.ItemType.Chip,
|
||||
Data.Models.Metadata.ItemType.Condition,
|
||||
Data.Models.Metadata.ItemType.Configuration,
|
||||
Data.Models.Metadata.ItemType.Device,
|
||||
Data.Models.Metadata.ItemType.DeviceRef,
|
||||
|
||||
@@ -273,9 +273,6 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case Data.Models.Metadata.ItemType.Chip:
|
||||
datItem = datItemObj.ToObject<Chip>();
|
||||
break;
|
||||
case Data.Models.Metadata.ItemType.Condition:
|
||||
datItem = datItemObj.ToObject<Condition>();
|
||||
break;
|
||||
case Data.Models.Metadata.ItemType.Configuration:
|
||||
datItem = datItemObj.ToObject<Configuration>();
|
||||
break;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +477,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
#region Adjuster
|
||||
|
||||
[Theory]
|
||||
[InlineData("adjuster.condition.mask", "mask")]
|
||||
[InlineData("adjuster.condition.relation", "ne")]
|
||||
[InlineData("adjuster.condition.tag", "tag")]
|
||||
[InlineData("adjuster.condition.value", "value")]
|
||||
[InlineData("adjuster.default", "yes")]
|
||||
[InlineData("adjuster.name", "name")]
|
||||
public void Matches_Adjsuter(string itemField, string value)
|
||||
@@ -484,6 +488,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Adjuster obj = new Adjuster
|
||||
{
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Relation.NotEqual,
|
||||
ConditionTag = "tag",
|
||||
ConditionValue = "value",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
};
|
||||
@@ -645,33 +653,13 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
|
||||
#endregion
|
||||
|
||||
#region Condition
|
||||
|
||||
[Theory]
|
||||
[InlineData("condition.mask", "mask")]
|
||||
[InlineData("condition.relation", "ne")]
|
||||
[InlineData("condition.tag", "tag")]
|
||||
[InlineData("condition.value", "value")]
|
||||
public void Matches_Condition(string itemField, string value)
|
||||
{
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Condition obj = new Condition
|
||||
{
|
||||
Mask = "mask",
|
||||
Relation = Relation.NotEqual,
|
||||
Tag = "tag",
|
||||
Value = "value",
|
||||
};
|
||||
|
||||
bool actual = filter.Matches(obj);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Configuration
|
||||
|
||||
[Theory]
|
||||
[InlineData("configuration.condition.mask", "mask")]
|
||||
[InlineData("configuration.condition.relation", "ne")]
|
||||
[InlineData("configuration.condition.tag", "tag")]
|
||||
[InlineData("configuration.condition.value", "value")]
|
||||
[InlineData("configuration.mask", "mask")]
|
||||
[InlineData("configuration.name", "name")]
|
||||
[InlineData("configuration.tag", "tag")]
|
||||
@@ -680,6 +668,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Configuration obj = new Configuration
|
||||
{
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Relation.NotEqual,
|
||||
ConditionTag = "tag",
|
||||
ConditionValue = "value",
|
||||
Mask = "mask",
|
||||
Name = "name",
|
||||
Tag = "tag",
|
||||
@@ -716,6 +708,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
#region ConfSetting
|
||||
|
||||
[Theory]
|
||||
[InlineData("confsetting.condition.mask", "mask")]
|
||||
[InlineData("confsetting.condition.relation", "ne")]
|
||||
[InlineData("confsetting.condition.tag", "tag")]
|
||||
[InlineData("confsetting.condition.value", "value")]
|
||||
[InlineData("confsetting.default", "yes")]
|
||||
[InlineData("confsetting.name", "name")]
|
||||
[InlineData("confsetting.value", "value")]
|
||||
@@ -724,6 +720,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
ConfSetting obj = new ConfSetting
|
||||
{
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Relation.NotEqual,
|
||||
ConditionTag = "tag",
|
||||
ConditionValue = "value",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
Value = "value",
|
||||
@@ -868,6 +868,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
#region DipSwitch
|
||||
|
||||
[Theory]
|
||||
[InlineData("dipswitch.condition.mask", "mask")]
|
||||
[InlineData("dipswitch.condition.relation", "ne")]
|
||||
[InlineData("dipswitch.condition.tag", "tag")]
|
||||
[InlineData("dipswitch.condition.value", "value")]
|
||||
[InlineData("dipswitch.default", "yes")]
|
||||
[InlineData("dipswitch.mask", "mask")]
|
||||
[InlineData("dipswitch.name", "name")]
|
||||
@@ -877,6 +881,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
DipSwitch obj = new DipSwitch
|
||||
{
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Relation.NotEqual,
|
||||
ConditionTag = "tag",
|
||||
ConditionValue = "value",
|
||||
Default = true,
|
||||
Mask = "mask",
|
||||
Name = "name",
|
||||
@@ -892,6 +900,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
#region DipValue
|
||||
|
||||
[Theory]
|
||||
[InlineData("dipvalue.condition.mask", "mask")]
|
||||
[InlineData("dipvalue.condition.relation", "ne")]
|
||||
[InlineData("dipvalue.condition.tag", "tag")]
|
||||
[InlineData("dipvalue.condition.value", "value")]
|
||||
[InlineData("dipvalue.default", "yes")]
|
||||
[InlineData("dipvalue.name", "name")]
|
||||
[InlineData("dipvalue.value", "value")]
|
||||
@@ -900,6 +912,10 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
DipValue obj = new DipValue
|
||||
{
|
||||
ConditionMask = "mask",
|
||||
ConditionRelation = Relation.NotEqual,
|
||||
ConditionTag = "tag",
|
||||
ConditionValue = "value",
|
||||
Default = true,
|
||||
Name = "name",
|
||||
Value = "value",
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace SabreTools.Metadata.Filter
|
||||
/// </summary>
|
||||
private static readonly string[] _adjusterKeys =
|
||||
[
|
||||
"condition.mask",
|
||||
"condition.relation",
|
||||
"condition.tag",
|
||||
"condition.value",
|
||||
"default",
|
||||
"name"
|
||||
];
|
||||
@@ -116,22 +120,15 @@ namespace SabreTools.Metadata.Filter
|
||||
"tag",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Condition
|
||||
/// </summary>
|
||||
private static readonly string[] _conditionKeys =
|
||||
[
|
||||
"mask",
|
||||
"relation",
|
||||
"tag",
|
||||
"value",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Configuration
|
||||
/// </summary>
|
||||
private static readonly string[] _configurationKeys =
|
||||
[
|
||||
"condition.mask",
|
||||
"condition.relation",
|
||||
"condition.tag",
|
||||
"condition.value",
|
||||
"mask",
|
||||
"name",
|
||||
"tag",
|
||||
@@ -152,6 +149,10 @@ namespace SabreTools.Metadata.Filter
|
||||
/// </summary>
|
||||
private static readonly string[] _confSettingKeys =
|
||||
[
|
||||
"condition.mask",
|
||||
"condition.relation",
|
||||
"condition.tag",
|
||||
"condition.value",
|
||||
"default",
|
||||
"name",
|
||||
"value",
|
||||
@@ -222,6 +223,10 @@ namespace SabreTools.Metadata.Filter
|
||||
/// </summary>
|
||||
private static readonly string[] _dipSwitchKeys =
|
||||
[
|
||||
"condition.mask",
|
||||
"condition.relation",
|
||||
"condition.tag",
|
||||
"condition.value",
|
||||
"default",
|
||||
"mask",
|
||||
"name",
|
||||
@@ -233,6 +238,10 @@ namespace SabreTools.Metadata.Filter
|
||||
/// </summary>
|
||||
private static readonly string[] _dipValueKeys =
|
||||
[
|
||||
"condition.mask",
|
||||
"condition.relation",
|
||||
"condition.tag",
|
||||
"condition.value",
|
||||
"default",
|
||||
"name",
|
||||
"value",
|
||||
@@ -876,12 +885,12 @@ namespace SabreTools.Metadata.Filter
|
||||
|
||||
// If we only have one part, we can't do anything
|
||||
string[] splitFilter = itemFieldString!.Split('.');
|
||||
if (splitFilter.Length != 2)
|
||||
if (splitFilter.Length < 2)
|
||||
return false;
|
||||
|
||||
// Set and sanitize the filter ID
|
||||
itemName = splitFilter[0];
|
||||
fieldName = splitFilter[1];
|
||||
fieldName = string.Join(".", splitFilter, 1, splitFilter.Length - 1);
|
||||
return ParseFilterId(ref itemName, ref fieldName);
|
||||
}
|
||||
|
||||
@@ -1014,7 +1023,6 @@ namespace SabreTools.Metadata.Filter
|
||||
"archive" => _archiveKeys,
|
||||
"biosset" => _biossetKeys,
|
||||
"chip" => _chipKeys,
|
||||
"condition" => _conditionKeys,
|
||||
"configuration" => _configurationKeys,
|
||||
"conflocation" => _confLocationKeys,
|
||||
"confsetting" => _confSettingKeys,
|
||||
|
||||
@@ -383,7 +383,6 @@ namespace SabreTools.Metadata.Filter
|
||||
case Archive item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case BiosSet item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case Chip item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case Condition item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case Configuration item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case ConfLocation item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
case ConfSetting item: return GetCheckValue(item, fieldName, out checkValue);
|
||||
@@ -508,6 +507,18 @@ namespace SabreTools.Metadata.Filter
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "condition.mask":
|
||||
checkValue = obj.ConditionMask;
|
||||
return true;
|
||||
case "condition.relation":
|
||||
checkValue = obj.ConditionRelation?.AsStringValue();
|
||||
return true;
|
||||
case "condition.tag":
|
||||
checkValue = obj.ConditionTag;
|
||||
return true;
|
||||
case "condition.value":
|
||||
checkValue = obj.ConditionValue;
|
||||
return true;
|
||||
case "default":
|
||||
checkValue = obj.Default.FromYesNo();
|
||||
return true;
|
||||
@@ -712,33 +723,6 @@ namespace SabreTools.Metadata.Filter
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the check value for a field
|
||||
/// </summary>
|
||||
private static bool GetCheckValue(Condition obj, string fieldName, out string? checkValue)
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "mask":
|
||||
checkValue = obj.Mask;
|
||||
return true;
|
||||
case "relation":
|
||||
checkValue = obj.Relation?.AsStringValue();
|
||||
return true;
|
||||
case "tag":
|
||||
checkValue = obj.Tag;
|
||||
return true;
|
||||
case "value":
|
||||
checkValue = obj.Value;
|
||||
return true;
|
||||
|
||||
// If the key doesn't exist, we count it as null
|
||||
default:
|
||||
checkValue = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the check value for a field
|
||||
/// </summary>
|
||||
@@ -746,6 +730,18 @@ namespace SabreTools.Metadata.Filter
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "condition.mask":
|
||||
checkValue = obj.ConditionMask;
|
||||
return true;
|
||||
case "condition.relation":
|
||||
checkValue = obj.ConditionRelation?.AsStringValue();
|
||||
return true;
|
||||
case "condition.tag":
|
||||
checkValue = obj.ConditionTag;
|
||||
return true;
|
||||
case "condition.value":
|
||||
checkValue = obj.ConditionValue;
|
||||
return true;
|
||||
case "mask":
|
||||
checkValue = obj.Mask;
|
||||
return true;
|
||||
@@ -794,6 +790,18 @@ namespace SabreTools.Metadata.Filter
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "condition.mask":
|
||||
checkValue = obj.ConditionMask;
|
||||
return true;
|
||||
case "condition.relation":
|
||||
checkValue = obj.ConditionRelation?.AsStringValue();
|
||||
return true;
|
||||
case "condition.tag":
|
||||
checkValue = obj.ConditionTag;
|
||||
return true;
|
||||
case "condition.value":
|
||||
checkValue = obj.ConditionValue;
|
||||
return true;
|
||||
case "default":
|
||||
checkValue = obj.Default.FromYesNo();
|
||||
return true;
|
||||
@@ -968,6 +976,18 @@ namespace SabreTools.Metadata.Filter
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "condition.mask":
|
||||
checkValue = obj.ConditionMask;
|
||||
return true;
|
||||
case "condition.relation":
|
||||
checkValue = obj.ConditionRelation?.AsStringValue();
|
||||
return true;
|
||||
case "condition.tag":
|
||||
checkValue = obj.ConditionTag;
|
||||
return true;
|
||||
case "condition.value":
|
||||
checkValue = obj.ConditionValue;
|
||||
return true;
|
||||
case "default":
|
||||
checkValue = obj.Default.FromYesNo();
|
||||
return true;
|
||||
@@ -995,6 +1015,18 @@ namespace SabreTools.Metadata.Filter
|
||||
{
|
||||
switch (fieldName)
|
||||
{
|
||||
case "condition.mask":
|
||||
checkValue = obj.ConditionMask;
|
||||
return true;
|
||||
case "condition.relation":
|
||||
checkValue = obj.ConditionRelation?.AsStringValue();
|
||||
return true;
|
||||
case "condition.tag":
|
||||
checkValue = obj.ConditionTag;
|
||||
return true;
|
||||
case "condition.value":
|
||||
checkValue = obj.ConditionValue;
|
||||
return true;
|
||||
case "default":
|
||||
checkValue = obj.Default.FromYesNo();
|
||||
return true;
|
||||
|
||||
@@ -152,9 +152,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
var condition = item.Condition;
|
||||
if (condition is not null)
|
||||
adjuster.Condition = ConvertFromInternalModel(condition);
|
||||
if (item.ConditionMask is not null
|
||||
|| item.ConditionRelation is not null
|
||||
|| item.ConditionTag is not null
|
||||
|| item.ConditionValue is not null)
|
||||
{
|
||||
adjuster.Condition = new Condition
|
||||
{
|
||||
Mask = item.ConditionMask,
|
||||
Relation = item.ConditionRelation,
|
||||
Tag = item.ConditionTag,
|
||||
Value = item.ConditionValue,
|
||||
};
|
||||
}
|
||||
|
||||
return adjuster;
|
||||
}
|
||||
@@ -201,21 +211,6 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return chip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Metadata.Condition"/> to <see cref="Condition"/>
|
||||
/// </summary>
|
||||
private static Condition ConvertFromInternalModel(Data.Models.Metadata.Condition item)
|
||||
{
|
||||
var condition = new Condition
|
||||
{
|
||||
Tag = item.Tag,
|
||||
Mask = item.Mask,
|
||||
Relation = item.Relation,
|
||||
Value = item.Value,
|
||||
};
|
||||
return condition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Metadata.Configuration"/> to <see cref="Configuration"/>
|
||||
/// </summary>
|
||||
@@ -228,9 +223,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Mask = item.Mask,
|
||||
};
|
||||
|
||||
var condition = item.Condition;
|
||||
if (condition is not null)
|
||||
configuration.Condition = ConvertFromInternalModel(condition);
|
||||
if (item.ConditionMask is not null
|
||||
|| item.ConditionRelation is not null
|
||||
|| item.ConditionTag is not null
|
||||
|| item.ConditionValue is not null)
|
||||
{
|
||||
configuration.Condition = new Condition
|
||||
{
|
||||
Mask = item.ConditionMask,
|
||||
Relation = item.ConditionRelation,
|
||||
Tag = item.ConditionTag,
|
||||
Value = item.ConditionValue,
|
||||
};
|
||||
}
|
||||
|
||||
var confLocations = item.ConfLocation;
|
||||
if (confLocations is not null && confLocations.Length > 0)
|
||||
@@ -269,9 +274,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
var condition = item.Condition;
|
||||
if (condition is not null)
|
||||
confSetting.Condition = ConvertFromInternalModel(condition);
|
||||
if (item.ConditionMask is not null
|
||||
|| item.ConditionRelation is not null
|
||||
|| item.ConditionTag is not null
|
||||
|| item.ConditionValue is not null)
|
||||
{
|
||||
confSetting.Condition = new Condition
|
||||
{
|
||||
Mask = item.ConditionMask,
|
||||
Relation = item.ConditionRelation,
|
||||
Tag = item.ConditionTag,
|
||||
Value = item.ConditionValue,
|
||||
};
|
||||
}
|
||||
|
||||
return confSetting;
|
||||
}
|
||||
@@ -362,9 +377,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Mask = item.Mask,
|
||||
};
|
||||
|
||||
var condition = item.Condition;
|
||||
if (condition is not null)
|
||||
dipSwitch.Condition = ConvertFromInternalModel(condition);
|
||||
if (item.ConditionMask is not null
|
||||
|| item.ConditionRelation is not null
|
||||
|| item.ConditionTag is not null
|
||||
|| item.ConditionValue is not null)
|
||||
{
|
||||
dipSwitch.Condition = new Condition
|
||||
{
|
||||
Mask = item.ConditionMask,
|
||||
Relation = item.ConditionRelation,
|
||||
Tag = item.ConditionTag,
|
||||
Value = item.ConditionValue,
|
||||
};
|
||||
}
|
||||
|
||||
var dipLocations = item.DipLocation;
|
||||
if (dipLocations is not null && dipLocations.Length > 0)
|
||||
@@ -389,9 +414,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
var condition = item.Condition;
|
||||
if (condition is not null)
|
||||
dipValue.Condition = ConvertFromInternalModel(condition);
|
||||
if (item.ConditionMask is not null
|
||||
|| item.ConditionRelation is not null
|
||||
|| item.ConditionTag is not null
|
||||
|| item.ConditionValue is not null)
|
||||
{
|
||||
dipValue.Condition = new Condition
|
||||
{
|
||||
Mask = item.ConditionMask,
|
||||
Relation = item.ConditionRelation,
|
||||
Tag = item.ConditionTag,
|
||||
Value = item.ConditionValue,
|
||||
};
|
||||
}
|
||||
|
||||
return dipValue;
|
||||
}
|
||||
|
||||
@@ -128,13 +128,14 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var adjuster = new Data.Models.Metadata.Adjuster
|
||||
{
|
||||
ConditionMask = item.Condition?.Mask,
|
||||
ConditionRelation = item.Condition?.Relation,
|
||||
ConditionTag = item.Condition?.Tag,
|
||||
ConditionValue = item.Condition?.Value,
|
||||
Name = item.Name,
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition is not null)
|
||||
adjuster.Condition = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return adjuster;
|
||||
}
|
||||
|
||||
@@ -180,21 +181,6 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return chip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Condition"/> to <see cref="Models.Metadata.Condition"/>
|
||||
/// </summary>
|
||||
private static Data.Models.Metadata.Condition ConvertToInternalModel(Condition item)
|
||||
{
|
||||
var condition = new Data.Models.Metadata.Condition
|
||||
{
|
||||
Tag = item.Tag,
|
||||
Mask = item.Mask,
|
||||
Relation = item.Relation,
|
||||
Value = item.Value,
|
||||
};
|
||||
return condition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Configuration"/> to <see cref="Models.Metadata.Configuration"/>
|
||||
/// </summary>
|
||||
@@ -202,14 +188,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var configuration = new Data.Models.Metadata.Configuration
|
||||
{
|
||||
ConditionMask = item.Condition?.Mask,
|
||||
ConditionRelation = item.Condition?.Relation,
|
||||
ConditionTag = item.Condition?.Tag,
|
||||
ConditionValue = item.Condition?.Value,
|
||||
Name = item.Name,
|
||||
Tag = item.Tag,
|
||||
Mask = item.Mask,
|
||||
};
|
||||
|
||||
if (item.Condition is not null)
|
||||
configuration.Condition = ConvertToInternalModel(item.Condition);
|
||||
|
||||
if (item.ConfLocation is not null && item.ConfLocation.Length > 0)
|
||||
configuration.ConfLocation = Array.ConvertAll(item.ConfLocation, ConvertToInternalModel);
|
||||
|
||||
@@ -240,14 +227,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var confSetting = new Data.Models.Metadata.ConfSetting
|
||||
{
|
||||
ConditionMask = item.Condition?.Mask,
|
||||
ConditionRelation = item.Condition?.Relation,
|
||||
ConditionTag = item.Condition?.Tag,
|
||||
ConditionValue = item.Condition?.Value,
|
||||
Name = item.Name,
|
||||
Value = item.Value,
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition is not null)
|
||||
confSetting.Condition = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return confSetting;
|
||||
}
|
||||
|
||||
@@ -330,14 +318,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var dipSwitch = new Data.Models.Metadata.DipSwitch
|
||||
{
|
||||
ConditionMask = item.Condition?.Mask,
|
||||
ConditionRelation = item.Condition?.Relation,
|
||||
ConditionTag = item.Condition?.Tag,
|
||||
ConditionValue = item.Condition?.Value,
|
||||
Name = item.Name,
|
||||
Tag = item.Tag,
|
||||
Mask = item.Mask,
|
||||
};
|
||||
|
||||
if (item.Condition is not null)
|
||||
dipSwitch.Condition = ConvertToInternalModel(item.Condition);
|
||||
|
||||
if (item.DipLocation is not null && item.DipLocation.Length > 0)
|
||||
dipSwitch.DipLocation = Array.ConvertAll(item.DipLocation, ConvertToInternalModel);
|
||||
|
||||
@@ -354,14 +343,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var dipValue = new Data.Models.Metadata.DipValue
|
||||
{
|
||||
ConditionMask = item.Condition?.Mask,
|
||||
ConditionRelation = item.Condition?.Relation,
|
||||
ConditionTag = item.Condition?.Tag,
|
||||
ConditionValue = item.Condition?.Value,
|
||||
Name = item.Name,
|
||||
Value = item.Value,
|
||||
Default = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition is not null)
|
||||
dipValue.Condition = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return dipValue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user