using System.Collections.Generic;
using System.Xml.Serialization;
using SabreTools.Core;
using Newtonsoft.Json;
namespace SabreTools.DatItems
{
///
/// Represents a single analog item
///
[JsonObject("analog"), XmlRoot("analog")]
public class Analog : DatItem
{
#region Fields
///
/// Analog mask value
///
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("mask")]
public string Mask { get; set; }
#endregion
#region Constructors
///
/// Create a default, empty Analog object
///
public Analog()
{
ItemType = ItemType.Analog;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new Analog()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Mask = this.Mask,
};
}
#endregion
#region Comparision Methods
public override bool Equals(DatItem other)
{
// If we don't have a Analog, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Analog
Analog newOther = other as Analog;
// If the Feature information matches
return (Mask == newOther.Mask);
}
#endregion
#region Sorting and Merging
///
public override void ReplaceFields(
DatItem item,
List datItemFields,
List machineFields)
{
// Replace common fields first
base.ReplaceFields(item, datItemFields, machineFields);
// If we don't have a Analog to replace from, ignore specific fields
if (item.ItemType != ItemType.Analog)
return;
// Cast for easier access
Analog newItem = item as Analog;
// Replace the fields
if (datItemFields.Contains(DatItemField.Analog_Mask))
Mask = newItem.Mask;
}
#endregion
}
}