Files
SabreTools/SabreTools.DatItems/Formats/Extension.cs

74 lines
1.8 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-02 16:37:01 -07:00
using Newtonsoft.Json;
2022-11-03 12:22:17 -07:00
using SabreTools.Core;
2020-09-02 16:37:01 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-02 16:37:01 -07:00
{
/// <summary>
/// Represents a matchable extension
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("extension"), XmlRoot("extension")]
2020-09-02 16:37:01 -07:00
public class Extension : DatItem
{
#region Fields
/// <summary>
/// Name of the item
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadString(Models.Internal.Extension.NameKey);
set => _internal[Models.Internal.Extension.NameKey] = value;
}
2020-09-02 16:37:01 -07:00
#endregion
#region Accessors
/// <inheritdoc/>
public override string? GetName() => Name;
2020-09-02 16:37:01 -07:00
/// <inheritdoc/>
public override void SetName(string? name) => Name = name;
2020-09-02 16:37:01 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Extension object
/// </summary>
public Extension()
{
2023-08-14 22:33:05 -04:00
_internal = new Models.Internal.Extension();
2023-08-15 01:38:01 -04:00
Machine = new Machine();
2020-09-02 16:37:01 -07:00
Name = string.Empty;
ItemType = ItemType.Extension;
}
#endregion
#region Cloning Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
2020-09-02 16:37:01 -07:00
public override object Clone()
{
return new Extension()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
2023-08-15 01:38:01 -04:00
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
2020-09-02 16:37:01 -07:00
Remove = this.Remove,
2020-09-03 13:01:33 -07:00
2023-08-14 22:33:05 -04:00
_internal = this._internal?.Clone() as Models.Internal.Extension ?? new Models.Internal.Extension(),
2020-09-02 16:37:01 -07:00
};
}
#endregion
}
}