Files
SabreTools.Serialization/SabreTools.Data.Models/Metadata/ConfSetting.cs

69 lines
1.9 KiB
C#
Raw Normal View History

using System;
2025-09-26 10:20:48 -04:00
using System.Xml.Serialization;
using Newtonsoft.Json;
2025-09-26 13:06:18 -04:00
namespace SabreTools.Data.Models.Metadata
2025-09-26 10:20:48 -04:00
{
[JsonObject("confsetting"), XmlRoot("confsetting")]
public class ConfSetting : DatItem, ICloneable, IEquatable<ConfSetting>
2025-09-26 10:20:48 -04:00
{
2026-04-01 13:18:45 -04:00
#region Properties
public Condition? Condition { get; set; }
2026-04-01 21:59:16 -04:00
/// <remarks>(yes|no) "no"</remarks>
2026-04-01 16:52:55 -04:00
public bool? Default { get; set; }
2026-04-01 13:18:45 -04:00
public string? Name { get; set; }
2026-04-02 11:18:49 -04:00
public string? Value { get; set; }
2026-04-01 13:18:45 -04:00
#endregion
public ConfSetting() => ItemType = ItemType.ConfSetting;
2025-09-26 10:20:48 -04:00
/// <inheritdoc/>
public object Clone()
{
var obj = new ConfSetting();
2025-09-26 10:20:48 -04:00
obj.Condition = Condition?.Clone() as Condition;
obj.Default = Default;
obj.Name = Name;
obj.Value = Value;
2025-09-26 10:20:48 -04:00
return obj;
}
/// <inheritdoc/>
public bool Equals(ConfSetting? other)
{
// Null never matches
if (other is null)
return false;
// Properties
if (Default != other.Default)
return false;
if ((Name is null) ^ (other.Name is null))
return false;
else if (Name is not null && !Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase))
return false;
if ((Value is null) ^ (other.Value is null))
return false;
else if (Value is not null && !Value.Equals(other.Value, StringComparison.OrdinalIgnoreCase))
return false;
// Sub-items
if ((Condition is null) ^ (other.Condition is null))
return false;
else if (Condition is not null && other.Condition is not null && Condition.Equals(other.Condition))
return false;
return true;
}
2025-09-26 10:20:48 -04:00
}
}