using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core.Tools; // TODO: Add item mappings for all fields namespace SabreTools.DatItems.Formats { /// /// Represents a single source details item /// [JsonObject("source_details"), XmlRoot("source_details")] public sealed class SourceDetails : DatItem { #region Fields /// /> protected override ItemType ItemType => ItemType.SourceDetails; /// /// Id value /// /// TODO: Is this required? [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("id")] public string? Id { get; set; } /// /// Section value /// [JsonProperty("section", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("section")] public string? Section { get; set; } /// /// Rom info value /// [JsonProperty("rominfo", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("rominfo")] public string? RomInfo { get; set; } /// /// Dumping date value /// [JsonProperty("d_date", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("d_date")] public string? DDate { get; set; } /// /// Dumping date info value /// [JsonProperty("d_date_info", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("d_date_info")] public string? DDateInfo { get; set; } /// /// Release date value /// [JsonProperty("r_date", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("r_date")] public string? RDate { get; set; } /// /// Release date info value /// [JsonProperty("r_date_info", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("r_date_info")] public string? RDateInfo { get; set; } /// /// Origin value /// [JsonProperty("origin", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("origin")] public string? Origin { get; set; } /// /// Region value /// [JsonProperty("region", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("region")] public string? Region { get; set; } /// /// Media title value /// [JsonProperty("media_title", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("media_title")] public string? MediaTitle { get; set; } /// /// Dumper value /// [JsonProperty("dumper", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("dumper")] public string? Dumper { get; set; } /// /// Project value /// [JsonProperty("project", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("project")] public string? Project { get; set; } /// /// Original format value /// [JsonProperty("originalformat", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("originalformat")] public string? OriginalFormat { get; set; } /// /// Nodump value /// [JsonProperty("nodump", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("nodump")] public string? Nodump { get; set; } /// /// Tool value /// [JsonProperty("tool", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tool")] public string? Tool { get; set; } /// /// Comment 1 value /// [JsonProperty("comment1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("comment1")] public string? Comment1 { get; set; } /// /// Link 2 value /// [JsonProperty("comment2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("comment2")] public string? Comment2 { get; set; } /// /// Link 1 value /// [JsonProperty("link1", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("link1")] public string? Link1 { get; set; } /// /// Link 2 value /// [JsonProperty("link2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("link2")] public string? Link2 { get; set; } /// /// Link 3 value /// [JsonProperty("link3", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("link3")] public string? Link3 { get; set; } #endregion #region Constructors /// /// Create a default, empty SourceDetails object /// public SourceDetails() { SetFieldValue(Models.Metadata.DatItem.TypeKey, ItemType.SourceDetails); } #endregion #region Cloning Methods /// public override object Clone() { var sourceDetails = new SourceDetails() { Id = this.Id, Section = this.Section, RomInfo = this.RomInfo, DDate = this.DDate, DDateInfo = this.DDateInfo, RDate = this.RDate, RDateInfo = this.RDateInfo, Origin = this.Origin, Region = this.Region, MediaTitle = this.MediaTitle, Dumper = this.Dumper, Project = this.Project, OriginalFormat = this.OriginalFormat, Nodump = this.Nodump, Tool = this.Tool, Comment1 = this.Comment1, Comment2 = this.Comment2, Link1 = this.Link1, Link2 = this.Link2, Link3 = this.Link3, }; sourceDetails.SetFieldValue(DatItem.DupeTypeKey, GetFieldValue(DatItem.DupeTypeKey)); sourceDetails.SetFieldValue(DatItem.MachineKey, GetMachine()); sourceDetails.SetFieldValue(DatItem.RemoveKey, GetBoolFieldValue(DatItem.RemoveKey)); sourceDetails.SetFieldValue(DatItem.SourceKey, GetFieldValue(DatItem.SourceKey)); sourceDetails.SetFieldValue(Models.Metadata.DatItem.TypeKey, GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsItemType().AsStringValue()); return sourceDetails; } #endregion #region Comparision Methods /// public override bool Equals(DatItem? other) { // If we don't have a SourceDetails, return false if (GetStringFieldValue(Models.Metadata.DatItem.TypeKey) != other?.GetStringFieldValue(Models.Metadata.DatItem.TypeKey)) return false; // Otherwise, treat it as a SourceDetails SourceDetails? newOther = other as SourceDetails; // If the Details information matches return (Id == newOther!.Id && Section == newOther.Section && RomInfo == newOther.RomInfo && DDate == newOther.DDate && DDateInfo == newOther.DDateInfo && RomInfo == newOther.RomInfo && RDate == newOther.RDate && RDateInfo == newOther.RDateInfo && Origin == newOther.Origin && Region == newOther.Region && MediaTitle == newOther.MediaTitle && Dumper == newOther.Dumper && Project == newOther.Project && OriginalFormat == newOther.OriginalFormat && Nodump == newOther.Nodump && Tool == newOther.Tool && Comment1 == newOther.Comment1 && Comment2 == newOther.Comment2 && Link1 == newOther.Link1 && Link2 == newOther.Link2 && Link3 == newOther.Link3); } #endregion } }