using System.Collections.Generic; using System.Xml.Serialization; using SabreTools.Core; using Newtonsoft.Json; namespace SabreTools.DatItems { /// /// SoftwareList diskarea information /// /// One DiskArea can contain multiple Disk items [JsonObject("diskarea"), XmlRoot("diskarea")] public class DiskArea : DatItem { #region Fields /// /// Name of the item /// [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] [XmlElement("name")] public string Name { get; set; } #endregion #region Accessors /// public override string GetName() => Name; /// public override void SetName(string name) => Name = name; #endregion #region Constructors /// /// Create a default, empty DiskArea object /// public DiskArea() { Name = string.Empty; ItemType = ItemType.DiskArea; } #endregion #region Cloning Methods public override object Clone() { return new DiskArea() { ItemType = this.ItemType, DupeType = this.DupeType, Machine = this.Machine.Clone() as Machine, Source = this.Source.Clone() as Source, Remove = this.Remove, Name = this.Name, }; } #endregion #region Comparision Methods public override bool Equals(DatItem other) { // If we don't have a DiskArea, return false if (ItemType != other.ItemType) return false; // Otherwise, treat it as a DiskArea DiskArea newOther = other as DiskArea; // If the DiskArea information matches return (Name == newOther.Name); } #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 DiskArea to replace from, ignore specific fields if (item.ItemType != ItemType.DiskArea) return; // Cast for easier access DiskArea newItem = item as DiskArea; // Replace the fields if (datItemFields.Contains(DatItemField.AreaName)) Name = newItem.Name; } #endregion } }