mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 14:55:11 +00:00
Further reduce use of GetName and SetName
This commit is contained in:
@@ -15,6 +15,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DictionaryBase or null
|
||||
/// </summary>
|
||||
/// TODO: Determine if this can be removed
|
||||
public static string? GetName(this DictionaryBase self)
|
||||
{
|
||||
if (self is null)
|
||||
@@ -75,6 +76,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DictionaryBase or null
|
||||
/// </summary>
|
||||
/// TODO: Determine if this can be removed
|
||||
public static void SetName(this DictionaryBase self, string? name)
|
||||
{
|
||||
if (self is null || string.IsNullOrEmpty(name))
|
||||
@@ -211,6 +213,8 @@ namespace SabreTools.Data.Extensions
|
||||
return releaseDetails.Clone() as ReleaseDetails;
|
||||
else if (self is Rom rom)
|
||||
return rom.Clone() as Rom;
|
||||
else if (self is Sample sample)
|
||||
return sample.Clone() as Sample;
|
||||
else if (self is Serials serials)
|
||||
return serials.Clone() as Serials;
|
||||
else if (self is SharedFeat sharedFeat)
|
||||
@@ -300,6 +304,7 @@ namespace SabreTools.Data.Extensions
|
||||
cloneMachine.Language = selfMachine.Language;
|
||||
cloneMachine.Location = selfMachine.Location;
|
||||
cloneMachine.Manufacturer = selfMachine.Manufacturer;
|
||||
cloneMachine.Name = selfMachine.Name;
|
||||
cloneMachine.Notes = selfMachine.Notes;
|
||||
cloneMachine.PlayedCount = selfMachine.PlayedCount;
|
||||
cloneMachine.PlayedTime = selfMachine.PlayedTime;
|
||||
@@ -322,9 +327,6 @@ namespace SabreTools.Data.Extensions
|
||||
cloneMachine.Year = selfMachine.Year;
|
||||
}
|
||||
|
||||
// Handle known properties
|
||||
clone.SetName(self.GetName());
|
||||
|
||||
// Loop through and clone per type
|
||||
foreach (string key in self.Keys)
|
||||
{
|
||||
|
||||
@@ -338,19 +338,15 @@ namespace SabreTools.Metadata.Filter
|
||||
/// </summary>
|
||||
private static bool GetCheckValue(DictionaryBase dictionaryBase, string fieldName, out string? checkValue)
|
||||
{
|
||||
// Handle the common name field
|
||||
if (fieldName == "name")
|
||||
{
|
||||
checkValue = dictionaryBase.GetName();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle type-specific properties
|
||||
switch (dictionaryBase)
|
||||
{
|
||||
case Adjuster item when fieldName == "default":
|
||||
checkValue = item.Default.FromYesNo();
|
||||
return true;
|
||||
case Adjuster item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Analog item when fieldName == "mask":
|
||||
checkValue = item.Mask;
|
||||
@@ -413,6 +409,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Archive item when fieldName == "mergename":
|
||||
checkValue = item.MergeName;
|
||||
return true;
|
||||
case Archive item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Archive item when fieldName == "namealt":
|
||||
checkValue = item.NameAlt;
|
||||
return true;
|
||||
@@ -459,6 +458,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case BiosSet item when fieldName == "description":
|
||||
checkValue = item.Description;
|
||||
return true;
|
||||
case BiosSet item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Chip item when fieldName == "type":
|
||||
checkValue = item.ChipType?.AsStringValue();
|
||||
@@ -469,6 +471,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Chip item when fieldName == "flags":
|
||||
checkValue = item.Flags;
|
||||
return true;
|
||||
case Chip item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Chip item when fieldName == "soundonly":
|
||||
checkValue = item.SoundOnly.FromYesNo();
|
||||
return true;
|
||||
@@ -492,6 +497,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Configuration item when fieldName == "mask":
|
||||
checkValue = item.Mask;
|
||||
return true;
|
||||
case Configuration item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Configuration item when fieldName == "tag":
|
||||
checkValue = item.Tag;
|
||||
return true;
|
||||
@@ -499,6 +507,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case ConfLocation item when fieldName == "inverted":
|
||||
checkValue = item.Inverted.FromYesNo();
|
||||
return true;
|
||||
case ConfLocation item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case ConfLocation item when fieldName == "number":
|
||||
checkValue = item.Number?.ToString();
|
||||
return true;
|
||||
@@ -506,6 +517,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case ConfSetting item when fieldName == "default":
|
||||
checkValue = item.Default.FromYesNo();
|
||||
return true;
|
||||
case ConfSetting item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case ConfSetting item when fieldName == "value":
|
||||
checkValue = item.Value;
|
||||
return true;
|
||||
@@ -550,6 +564,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case DataArea item when fieldName == "endianness":
|
||||
checkValue = item.Endianness?.AsStringValue();
|
||||
return true;
|
||||
case DataArea item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case DataArea item when fieldName == "size":
|
||||
checkValue = item.Size?.ToString();
|
||||
return true;
|
||||
@@ -573,9 +590,16 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Tag;
|
||||
return true;
|
||||
|
||||
case DeviceRef item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case DipLocation item when fieldName == "inverted":
|
||||
checkValue = item.Inverted.FromYesNo();
|
||||
return true;
|
||||
case DipLocation item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case DipLocation item when fieldName == "number":
|
||||
checkValue = item.Number?.ToString();
|
||||
return true;
|
||||
@@ -586,6 +610,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case DipSwitch item when fieldName == "mask":
|
||||
checkValue = item.Mask;
|
||||
return true;
|
||||
case DipSwitch item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case DipSwitch item when fieldName == "tag":
|
||||
checkValue = item.Tag;
|
||||
return true;
|
||||
@@ -593,6 +620,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case DipValue item when fieldName == "default":
|
||||
checkValue = item.Default.FromYesNo();
|
||||
return true;
|
||||
case DipValue item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case DipValue item when fieldName == "value":
|
||||
checkValue = item.Value;
|
||||
return true;
|
||||
@@ -609,6 +639,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Disk item when fieldName == "merge":
|
||||
checkValue = item.Merge;
|
||||
return true;
|
||||
case Disk item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Disk item when fieldName == "optional":
|
||||
checkValue = item.Optional.FromYesNo();
|
||||
return true;
|
||||
@@ -625,6 +658,10 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Writable.FromYesNo();
|
||||
return true;
|
||||
|
||||
case DiskArea item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Display item when fieldName == "aspectx":
|
||||
checkValue = item.AspectX?.ToString();
|
||||
return true;
|
||||
@@ -711,6 +748,13 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Unofficial.FromYesNo();
|
||||
return true;
|
||||
|
||||
case Extension item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Feature item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Feature item when fieldName == "overall":
|
||||
checkValue = item.Overall?.AsStringValue();
|
||||
return true;
|
||||
@@ -787,6 +831,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Header item when fieldName == "mameconfig":
|
||||
checkValue = item.MameConfig;
|
||||
return true;
|
||||
case Header item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Header item when fieldName == "notes":
|
||||
checkValue = item.Notes;
|
||||
return true;
|
||||
@@ -824,6 +871,9 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Version;
|
||||
return true;
|
||||
|
||||
case Info item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Info item when fieldName == "value":
|
||||
checkValue = item.Value;
|
||||
return true;
|
||||
@@ -847,6 +897,10 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Tilt.FromYesNo();
|
||||
return true;
|
||||
|
||||
case Instance item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Machine item when fieldName == "board":
|
||||
checkValue = item.Board;
|
||||
return true;
|
||||
@@ -931,6 +985,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Machine item when fieldName == "manufacturer":
|
||||
checkValue = item.Manufacturer;
|
||||
return true;
|
||||
case Machine item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Machine item when fieldName == "notes":
|
||||
checkValue = item.Notes;
|
||||
return true;
|
||||
@@ -995,6 +1052,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Media item when fieldName == "md5":
|
||||
checkValue = item.MD5;
|
||||
return true;
|
||||
case Media item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Media item when fieldName == "sha1":
|
||||
checkValue = item.SHA1;
|
||||
return true;
|
||||
@@ -1015,6 +1075,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Part item when fieldName == "interface":
|
||||
checkValue = item.Interface;
|
||||
return true;
|
||||
case Part item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Port item when fieldName == "tag":
|
||||
checkValue = item.Tag;
|
||||
@@ -1026,6 +1089,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case RamOption item when fieldName == "default":
|
||||
checkValue = item.Default.FromYesNo();
|
||||
return true;
|
||||
case RamOption item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Release item when fieldName == "date":
|
||||
checkValue = item.Date;
|
||||
@@ -1036,6 +1102,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Release item when fieldName == "language":
|
||||
checkValue = item.Language;
|
||||
return true;
|
||||
case Release item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Release item when fieldName == "region":
|
||||
checkValue = item.Region;
|
||||
return true;
|
||||
@@ -1110,6 +1179,9 @@ namespace SabreTools.Metadata.Filter
|
||||
case Rom item when fieldName == "mia":
|
||||
checkValue = item.MIA.FromYesNo();
|
||||
return true;
|
||||
case Rom item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case Rom item when fieldName == "optional":
|
||||
checkValue = item.Optional.FromYesNo();
|
||||
return true;
|
||||
@@ -1126,6 +1198,10 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.Value;
|
||||
return true;
|
||||
|
||||
case Sample item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case Serials item when fieldName == "boxbarcode":
|
||||
checkValue = item.BoxBarcode;
|
||||
return true;
|
||||
@@ -1169,20 +1245,33 @@ namespace SabreTools.Metadata.Filter
|
||||
checkValue = item.SaveChipSerial;
|
||||
return true;
|
||||
|
||||
case SharedFeat item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case SharedFeat item when fieldName == "value":
|
||||
checkValue = item.Value;
|
||||
return true;
|
||||
|
||||
case Slot item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case SlotOption item when fieldName == "default":
|
||||
checkValue = item.Default.FromYesNo();
|
||||
return true;
|
||||
case SlotOption item when fieldName == "devname":
|
||||
checkValue = item.DevName;
|
||||
return true;
|
||||
case SlotOption item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
|
||||
case SoftwareList item when fieldName == "filter":
|
||||
checkValue = item.Filter;
|
||||
return true;
|
||||
case SoftwareList item when fieldName == "name":
|
||||
checkValue = item.Name;
|
||||
return true;
|
||||
case SoftwareList item when fieldName == "status":
|
||||
checkValue = item.Status?.AsStringValue();
|
||||
return true;
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace SabreTools.Metadata
|
||||
return false;
|
||||
|
||||
// Check names
|
||||
if (self.GetName() != other.GetName())
|
||||
return false;
|
||||
// if (self.GetName() != other.GetName())
|
||||
// return false;
|
||||
|
||||
// Handle individual type properties
|
||||
if (self is Adjuster selfAdjuster && other is Adjuster otherAdjuster)
|
||||
|
||||
Reference in New Issue
Block a user