2020-09-01 11:55:11 -07:00
|
|
|
|
using System.Collections.Generic;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
using System.Linq;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-01 11:55:11 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-01 11:55:11 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents which Configuration(s) is associated with a set
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("configuration"), XmlRoot("configuration")]
|
2020-09-01 11:55:11 -07:00
|
|
|
|
public class Configuration : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tag associated with the configuration
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tag")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Tag
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
get => _internal.ReadString(Models.Metadata.Configuration.TagKey);
|
|
|
|
|
|
set => _internal[Models.Metadata.Configuration.TagKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Mask associated with the configuration
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("mask")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Mask
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
get => _internal.ReadString(Models.Metadata.Configuration.MaskKey);
|
|
|
|
|
|
set => _internal[Models.Metadata.Configuration.MaskKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Conditions associated with the configuration
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("conditions")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<Condition>? Conditions
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
get => _internal.Read<Condition[]>(Models.Metadata.Configuration.ConditionKey)?.ToList();
|
|
|
|
|
|
set => _internal[Models.Metadata.Configuration.ConditionKey] = value?.ToArray();
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
|
|
|
|
|
|
2020-09-01 11:55:11 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Locations associated with the configuration
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("locations", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("locations")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<ConfLocation>? Locations
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
get => _internal.Read<ConfLocation[]>(Models.Metadata.Configuration.ConfLocationKey)?.ToList();
|
|
|
|
|
|
set => _internal[Models.Metadata.Configuration.ConfLocationKey] = value?.ToArray();
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool LocationsSpecified { get { return Locations != null && Locations.Count > 0; } }
|
|
|
|
|
|
|
2020-09-01 11:55:11 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Settings associated with the configuration
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("settings", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("settings")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<ConfSetting>? Settings
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
get => _internal.Read<List<ConfSetting>>(Models.Metadata.Configuration.ConfSettingKey);
|
|
|
|
|
|
set => _internal[Models.Metadata.Configuration.ConfSettingKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:55:11 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool SettingsSpecified { get { return Settings != null && Settings.Count > 0; } }
|
|
|
|
|
|
|
2020-09-01 11:55:11 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
|
public override string? GetName() => GetFieldValue<string>(Models.Metadata.Configuration.NameKey);
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-03-08 15:31:21 -05:00
|
|
|
|
public override void SetName(string? name) => SetFieldValue(Models.Metadata.Configuration.NameKey, name);
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-01 11:55:11 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Configuration object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Configuration()
|
|
|
|
|
|
{
|
2023-09-04 23:51:37 -04:00
|
|
|
|
_internal = new Models.Metadata.Configuration();
|
2023-08-15 01:38:01 -04:00
|
|
|
|
Machine = new Machine();
|
|
|
|
|
|
|
2024-03-08 20:42:24 -05:00
|
|
|
|
SetName(string.Empty);
|
2020-09-01 11:55:11 -07:00
|
|
|
|
ItemType = ItemType.Configuration;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-01 11:55:11 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Configuration()
|
|
|
|
|
|
{
|
|
|
|
|
|
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,
|
2020-09-01 11:55:11 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2024-02-28 19:19:50 -05:00
|
|
|
|
_internal = this._internal?.Clone() as Models.Metadata.Configuration ?? [],
|
2020-09-01 11:55:11 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|