mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-05-06 20:43:36 +00:00
82 lines
2.3 KiB
C#
82 lines
2.3 KiB
C#
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using SabreTools.Data.Extensions;
|
|
|
|
namespace SabreTools.Metadata.DatItems.Formats
|
|
{
|
|
/// <summary>
|
|
/// Represents one ListXML dipvalue
|
|
/// </summary>
|
|
[JsonObject("dipvalue"), XmlRoot("dipvalue")]
|
|
public sealed class DipValue : DatItem<Data.Models.Metadata.DipValue>
|
|
{
|
|
#region Fields
|
|
|
|
public Condition? Condition { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool ConditionSpecified => Condition is not null;
|
|
|
|
public bool? Default
|
|
{
|
|
get => (_internal as Data.Models.Metadata.DipValue)?.Default;
|
|
set => (_internal as Data.Models.Metadata.DipValue)?.Default = value;
|
|
}
|
|
|
|
/// <inheritdoc>/>
|
|
public override Data.Models.Metadata.ItemType ItemType
|
|
=> Data.Models.Metadata.ItemType.DipValue;
|
|
|
|
public string? Name
|
|
{
|
|
get => (_internal as Data.Models.Metadata.DipValue)?.Name;
|
|
set => (_internal as Data.Models.Metadata.DipValue)?.Name = value;
|
|
}
|
|
|
|
public string? Value
|
|
{
|
|
get => (_internal as Data.Models.Metadata.DipValue)?.Value;
|
|
set => (_internal as Data.Models.Metadata.DipValue)?.Value = value;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
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, Machine machine, Source source) : this(item)
|
|
{
|
|
Source = source;
|
|
CopyMachineInformation(machine);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Cloning Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override object Clone() => new DipValue(_internal.DeepClone() as Data.Models.Metadata.DipValue ?? []);
|
|
|
|
/// <inheritdoc/>
|
|
public override Data.Models.Metadata.DipValue GetInternalClone()
|
|
{
|
|
var dipValueItem = base.GetInternalClone();
|
|
|
|
if (Condition is not null)
|
|
dipValueItem.Condition = Condition.GetInternalClone();
|
|
|
|
return dipValueItem;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|