mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
112 lines
3.2 KiB
C#
112 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using SabreTools.Core;
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
{
|
|
/// <summary>
|
|
/// Represents one ListXML dipvalue
|
|
/// </summary>
|
|
[JsonObject("dipvalue"), XmlRoot("dipvalue")]
|
|
public class DipValue : DatItem
|
|
{
|
|
#region Fields
|
|
|
|
/// <summary>
|
|
/// Setting name
|
|
/// </summary>
|
|
[JsonProperty("name"), XmlElement("name")]
|
|
public string? Name
|
|
{
|
|
get => _internal.ReadString(Models.Metadata.DipValue.NameKey);
|
|
set => _internal[Models.Metadata.DipValue.NameKey] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Setting value
|
|
/// </summary>
|
|
[JsonProperty("value", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("value")]
|
|
public string? Value
|
|
{
|
|
get => _internal.ReadString(Models.Metadata.DipValue.ValueKey);
|
|
set => _internal[Models.Metadata.DipValue.ValueKey] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines if the setting is default or not
|
|
/// </summary>
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
|
public bool? Default
|
|
{
|
|
get => _internal.ReadBool(Models.Metadata.DipValue.DefaultKey);
|
|
set => _internal[Models.Metadata.DipValue.DefaultKey] = value;
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
/// <summary>
|
|
/// List of conditions on the setting
|
|
/// </summary>
|
|
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("conditions")]
|
|
public List<Condition>? Conditions
|
|
{
|
|
get => _internal.Read<Condition[]>(Models.Metadata.DipValue.ConditionKey)?.ToList();
|
|
set => _internal[Models.Metadata.DipValue.ConditionKey] = value?.ToArray();
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
|
|
|
#endregion
|
|
|
|
#region Accessors
|
|
|
|
/// <inheritdoc/>
|
|
public override string? GetName() => Name;
|
|
|
|
/// <inheritdoc/>
|
|
public override void SetName(string? name) => Name = name;
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Create a default, empty DipValue object
|
|
/// </summary>
|
|
public DipValue()
|
|
{
|
|
_internal = new Models.Metadata.DipValue();
|
|
Machine = new Machine();
|
|
|
|
Name = string.Empty;
|
|
ItemType = ItemType.DipValue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Cloning Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override object Clone()
|
|
{
|
|
return new DipValue()
|
|
{
|
|
ItemType = this.ItemType,
|
|
DupeType = this.DupeType,
|
|
|
|
Machine = this.Machine.Clone() as Machine ?? new Machine(),
|
|
Source = this.Source?.Clone() as Source,
|
|
Remove = this.Remove,
|
|
|
|
_internal = this._internal?.Clone() as Models.Metadata.DipValue ?? [],
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|