2023-08-14 13:17:51 -04:00
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SabreTools.Core;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents one ListXML confsetting
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonObject("confsetting"), XmlRoot("confsetting")]
|
|
|
|
|
public class ConfSetting : DatItem
|
|
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
[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 Accessors
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
public override string? GetName() => GetFieldValue<string>(Models.Metadata.ConfSetting.NameKey);
|
2023-08-14 13:17:51 -04:00
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
public override void SetName(string? name) => SetFieldValue(Models.Metadata.ConfSetting.NameKey, name);
|
2023-08-14 13:17:51 -04:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a default, empty ConfSetting object
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ConfSetting()
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
_internal = new Models.Metadata.ConfSetting();
|
2023-08-15 01:38:01 -04:00
|
|
|
Machine = new Machine();
|
|
|
|
|
|
2024-03-08 20:42:24 -05:00
|
|
|
SetName(string.Empty);
|
2023-08-14 13:17:51 -04:00
|
|
|
ItemType = ItemType.ConfSetting;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-09 21:46:38 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Create a ConfSetting object from the internal model
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ConfSetting(Models.Metadata.ConfSetting? item)
|
|
|
|
|
{
|
|
|
|
|
_internal = item ?? [];
|
|
|
|
|
Machine = new Machine();
|
|
|
|
|
|
|
|
|
|
ItemType = ItemType.ConfSetting;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override object Clone()
|
|
|
|
|
{
|
|
|
|
|
return new ConfSetting()
|
|
|
|
|
{
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
2023-08-15 01:38:01 -04:00
|
|
|
Machine = this.Machine.Clone() as Machine ?? new Machine(),
|
2023-08-14 13:17:51 -04:00
|
|
|
Source = this.Source?.Clone() as Source,
|
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
2024-02-28 19:19:50 -05:00
|
|
|
_internal = this._internal?.Clone() as Models.Metadata.ConfSetting ?? [],
|
2023-08-14 13:17:51 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|