2020-12-14 10:58:43 -08:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-01 11:34:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents which RAM option(s) is associated with a set
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("ramoption"), XmlRoot("ramoption")]
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public class RamOption : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
2020-09-02 12:19:12 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Name of the item
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("name"), XmlElement("name")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _ramOption.ReadString(Models.Internal.RamOption.NameKey);
|
|
|
|
|
|
set => _ramOption[Models.Internal.RamOption.NameKey] = value;
|
|
|
|
|
|
}
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determine whether the RamOption is default
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public bool? Default
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _ramOption.ReadBool(Models.Internal.RamOption.DefaultKey);
|
|
|
|
|
|
set => _ramOption[Models.Internal.RamOption.DefaultKey] = value;
|
|
|
|
|
|
}
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines the content of the RamOption
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("content")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Content
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _ramOption.ReadString(Models.Internal.RamOption.ContentKey);
|
|
|
|
|
|
set => _ramOption[Models.Internal.RamOption.ContentKey] = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Internal RamOption model
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
private Models.Internal.RamOption _ramOption = new();
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override string? GetName() => Name;
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override void SetName(string? name) => Name = name;
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty RamOption object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public RamOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = string.Empty;
|
|
|
|
|
|
ItemType = ItemType.RamOption;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new RamOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Machine = this.Machine?.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source?.Clone() as Source,
|
2020-09-01 11:34:52 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
_ramOption = this._ramOption?.Clone() as Models.Internal.RamOption ?? new Models.Internal.RamOption(),
|
2020-09-01 11:34:52 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override bool Equals(DatItem? other)
|
2020-09-01 11:34:52 -07:00
|
|
|
|
{
|
2023-08-14 13:17:51 -04:00
|
|
|
|
// If we don't have a RamOption, return false
|
|
|
|
|
|
if (ItemType != other?.ItemType || other is not RamOption otherInternal)
|
2020-09-01 11:34:52 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
// Compare the internal models
|
|
|
|
|
|
return _ramOption.EqualTo(otherInternal._ramOption);
|
2020-09-01 11:34:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|