2023-08-14 13:17:51 -04:00
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
using Newtonsoft.Json;
|
2025-01-11 22:00:26 -05:00
|
|
|
using SabreTools.Core.Tools;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents one ListXML confsetting
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonObject("confsetting"), XmlRoot("confsetting")]
|
2024-03-10 20:39:54 -04:00
|
|
|
public sealed class ConfSetting : DatItem<Models.Metadata.ConfSetting>
|
2023-08-14 13:17:51 -04:00
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
|
2024-03-10 20:39:54 -04:00
|
|
|
/// <inheritdoc>/>
|
|
|
|
|
protected override ItemType ItemType => ItemType.ConfSetting;
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc>/>
|
|
|
|
|
protected override string? NameKey => Models.Metadata.ConfSetting.NameKey;
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
[JsonIgnore]
|
2024-03-09 21:34:26 -05:00
|
|
|
public bool ConditionsSpecified
|
2023-08-14 13:17:51 -04:00
|
|
|
{
|
2024-03-09 21:34:26 -05:00
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var conditions = GetFieldValue<Condition[]?>(Models.Metadata.ConfSetting.ConditionKey);
|
|
|
|
|
return conditions != null && conditions.Length > 0;
|
|
|
|
|
}
|
2023-08-14 13:17:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
2024-03-10 20:39:54 -04:00
|
|
|
public ConfSetting() : base() { }
|
2025-01-11 22:00:26 -05:00
|
|
|
public ConfSetting(Models.Metadata.ConfSetting item) : base(item)
|
|
|
|
|
{
|
|
|
|
|
// Process flag values
|
|
|
|
|
if (GetBoolFieldValue(Models.Metadata.ConfSetting.DefaultKey) != null)
|
|
|
|
|
SetFieldValue<string?>(Models.Metadata.ConfSetting.DefaultKey, GetBoolFieldValue(Models.Metadata.ConfSetting.DefaultKey).FromYesNo());
|
|
|
|
|
|
|
|
|
|
// Handle subitems
|
|
|
|
|
var condition = GetFieldValue<Models.Metadata.Condition>(Models.Metadata.ConfSetting.ConditionKey);
|
|
|
|
|
if (condition != null)
|
|
|
|
|
SetFieldValue<Condition?>(Models.Metadata.ConfSetting.ConditionKey, new Condition(condition));
|
|
|
|
|
}
|
2023-08-14 13:17:51 -04:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|