Files
SabreTools/SabreTools.DatItems/Formats/Feature.cs

103 lines
2.8 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-02 13:31:50 -07:00
2020-12-08 13:23:59 -08:00
using SabreTools.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2020-09-02 13:31:50 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-02 13:31:50 -07:00
{
/// <summary>
/// Represents the a feature of the machine
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("feature"), XmlRoot("feature")]
2020-09-02 13:31:50 -07:00
public class Feature : DatItem
{
#region Fields
/// <summary>
/// Type of feature
/// </summary>
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("type")]
2020-09-02 14:04:02 -07:00
public FeatureType Type { get; set; }
2020-09-02 13:31:50 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool TypeSpecified { get { return Type != FeatureType.NULL; } }
2020-09-02 13:31:50 -07:00
/// <summary>
/// Emulation status
/// </summary>
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("status")]
2020-09-02 14:34:41 -07:00
public FeatureStatus Status { get; set; }
2020-09-02 13:31:50 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool StatusSpecified { get { return Status != FeatureStatus.NULL; } }
2020-09-02 13:31:50 -07:00
/// <summary>
/// Overall status
/// </summary>
[JsonProperty("overall", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("overall")]
2020-09-02 14:34:41 -07:00
public FeatureStatus Overall { get; set; }
2020-09-02 13:31:50 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool OverallSpecified { get { return Overall != FeatureStatus.NULL; } }
2020-09-02 13:31:50 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Feature object
/// </summary>
public Feature()
{
ItemType = ItemType.Feature;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new Feature()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Type = this.Type,
Status = this.Status,
Overall = this.Overall,
};
}
#endregion
#region Comparision Methods
public override bool Equals(DatItem other)
{
// If we don't have a Feature, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Feature
Feature newOther = other as Feature;
// If the Feature information matches
return (Type == newOther.Type && Status == newOther.Status && Overall == newOther.Overall);
}
#endregion
}
}