using System.Xml.Serialization; using Newtonsoft.Json; namespace SabreTools.Metadata.DatItems.Formats { /// /// Represents a single instance of another item /// [JsonObject("instance"), XmlRoot("instance")] public sealed class Instance : DatItem { #region Properties public string? BriefName { get => (_internal as Data.Models.Metadata.Instance)?.BriefName; set => (_internal as Data.Models.Metadata.Instance)?.BriefName = value; } /// /> public override Data.Models.Metadata.ItemType ItemType => Data.Models.Metadata.ItemType.Instance; public string? Name { get => (_internal as Data.Models.Metadata.Instance)?.Name; set => (_internal as Data.Models.Metadata.Instance)?.Name = value; } #endregion #region Constructors public Instance() : base() { } public Instance(Data.Models.Metadata.Instance item) : base(item) { } public Instance(Data.Models.Metadata.Instance item, Machine machine, Source source) : this(item) { Source = source; CopyMachineInformation(machine); } #endregion #region Accessors /// public override string? GetName() => Name; /// public override void SetName(string? name) => Name = name; #endregion #region Cloning Methods /// public override object Clone() => new Instance(GetInternalClone()); /// public override Data.Models.Metadata.Instance GetInternalClone() => (_internal as Data.Models.Metadata.Instance)?.Clone() as Data.Models.Metadata.Instance ?? new(); #endregion #region Comparision Methods /// public override bool Equals(ModelBackedItem? other) { // If the other item is null if (other is null) return false; // If the type matches if (other is Instance otherInstance) return ((Data.Models.Metadata.Instance)_internal).Equals((Data.Models.Metadata.Instance)otherInstance._internal); // Everything else fails return false; } /// public override bool Equals(ModelBackedItem? other) { // If the other item is null if (other is null) return false; // If the type matches if (other is Instance otherInstance) return ((Data.Models.Metadata.Instance)_internal).Equals((Data.Models.Metadata.Instance)otherInstance._internal); // Everything else fails return false; } /// public override bool Equals(DatItem? other) { // If the other item is null if (other is null) return false; // If the type matches if (other is Instance otherInstance) return ((Data.Models.Metadata.Instance)_internal).Equals((Data.Models.Metadata.Instance)otherInstance._internal); // Everything else fails return false; } /// public override bool Equals(DatItem? other) { // If the other value is invalid if (other is null) return false; // If the type matches if (other is Instance otherInstance) return ((Data.Models.Metadata.Instance)_internal).Equals((Data.Models.Metadata.Instance)otherInstance._internal); // Everything else fails return false; } #endregion } }