mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 06:45:11 +00:00
Move common string-only to properties
This commit is contained in:
@@ -125,7 +125,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.GetName();
|
||||
string? machineDesc = machine.ReadString(Data.Models.Metadata.Machine.DescriptionKey);
|
||||
string? machineDesc = machine.Description;
|
||||
if (machineName is null || machineDesc is null)
|
||||
continue;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Value.GetName();
|
||||
string? machineDesc = machine.Value.ReadString(Data.Models.Metadata.Machine.DescriptionKey);
|
||||
string? machineDesc = machine.Value.Description;
|
||||
if (machineName is null || machineDesc is null)
|
||||
continue;
|
||||
|
||||
@@ -652,13 +652,13 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.GetName();
|
||||
string? machineDesc = machine.ReadString(Data.Models.Metadata.Machine.DescriptionKey);
|
||||
string? machineDesc = machine.Description;
|
||||
|
||||
if (machineName is not null && Regex.IsMatch(machineName, SceneNamePattern))
|
||||
item.GetMachine()!.SetName(Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
|
||||
if (machineDesc is not null && Regex.IsMatch(machineDesc, SceneNamePattern))
|
||||
item.GetMachine()!.Write<string?>(Data.Models.Metadata.Machine.DescriptionKey, Regex.Replace(machineDesc, SceneNamePattern, "$2"));
|
||||
item.GetMachine()!.Description = Regex.Replace(machineDesc, SceneNamePattern, "$2");
|
||||
}
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
});
|
||||
@@ -690,13 +690,13 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Value.GetName();
|
||||
string? machineDesc = machine.Value.ReadString(Data.Models.Metadata.Machine.DescriptionKey);
|
||||
string? machineDesc = machine.Value.Description;
|
||||
|
||||
if (machineName is not null && Regex.IsMatch(machineName, SceneNamePattern))
|
||||
machine.Value.SetName(Regex.Replace(machineName, SceneNamePattern, "$2"));
|
||||
|
||||
if (machineDesc is not null && Regex.IsMatch(machineDesc, SceneNamePattern))
|
||||
machine.Value.Write<string?>(Data.Models.Metadata.Machine.DescriptionKey, Regex.Replace(machineDesc, SceneNamePattern, "$2"));
|
||||
machine.Value.Description = Regex.Replace(machineDesc, SceneNamePattern, "$2");
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
});
|
||||
#else
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace SabreTools.Metadata.DatFiles
|
||||
Header.Write<string?>(Data.Models.Metadata.Header.DatVersionKey, header.ReadString(Data.Models.Metadata.Header.DatVersionKey));
|
||||
if (Header.Debug is null)
|
||||
Header.Debug = header.Debug;
|
||||
if (Header.ReadString(Data.Models.Metadata.Header.DescriptionKey) is null)
|
||||
Header.Write<string?>(Data.Models.Metadata.Header.DescriptionKey, header.ReadString(Data.Models.Metadata.Header.DescriptionKey));
|
||||
if (Header.Description is null)
|
||||
Header.Description = header.Description;
|
||||
if (Header.ReadString(Data.Models.Metadata.Header.EmailKey) is null)
|
||||
Header.Write<string?>(Data.Models.Metadata.Header.EmailKey, header.ReadString(Data.Models.Metadata.Header.EmailKey));
|
||||
if (Header.ReadString(Data.Models.Metadata.Header.EmulatorVersionKey) is null)
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
copyFrom = new Rom();
|
||||
copyFrom.GetMachine()!.SetName(cloneOf);
|
||||
copyFrom.GetMachine()!.Write<string?>(Data.Models.Metadata.Machine.DescriptionKey, cloneOf);
|
||||
copyFrom.GetMachine()!.Description = cloneOf;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
// Get the header strings
|
||||
string? name = Header.Name;
|
||||
string? description = Header.ReadString(Data.Models.Metadata.Header.DescriptionKey);
|
||||
string? description = Header.Description;
|
||||
string? date = Header.ReadString(Data.Models.Metadata.Header.DateKey);
|
||||
|
||||
// If the description is defined but not the name, set the name from the description
|
||||
@@ -130,7 +130,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
// Set the fields back
|
||||
Header.Name = name;
|
||||
Header.Write<string?>(Data.Models.Metadata.Header.DescriptionKey, description);
|
||||
Header.Description = description;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -31,12 +31,6 @@ namespace SabreTools.Metadata.DatFiles
|
||||
|
||||
#region Fields
|
||||
|
||||
public string? Name
|
||||
{
|
||||
get => _internal.Name;
|
||||
set => _internal.Name = value;
|
||||
}
|
||||
|
||||
public MergingFlag BiosMode
|
||||
{
|
||||
get => _internal.BiosMode;
|
||||
@@ -59,6 +53,12 @@ namespace SabreTools.Metadata.DatFiles
|
||||
set => _internal.Debug = value;
|
||||
}
|
||||
|
||||
public string? Description
|
||||
{
|
||||
get => _internal.Description;
|
||||
set => _internal.Description = value;
|
||||
}
|
||||
|
||||
public MergingFlag ForceMerging
|
||||
{
|
||||
get => _internal.ForceMerging;
|
||||
@@ -119,6 +119,12 @@ namespace SabreTools.Metadata.DatFiles
|
||||
set => _internal.LockSampleMode = value;
|
||||
}
|
||||
|
||||
public string? Name
|
||||
{
|
||||
get => _internal.Name;
|
||||
set => _internal.Name = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NewDatSpecified
|
||||
{
|
||||
|
||||
@@ -83,8 +83,8 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrEmpty(biosset.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Name));
|
||||
if (string.IsNullOrEmpty(biosset.ReadString(Data.Models.Metadata.BiosSet.DescriptionKey)))
|
||||
missingFields.Add(Data.Models.Metadata.BiosSet.DescriptionKey);
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Description));
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
|
||||
@@ -262,8 +262,8 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrEmpty(biosset.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Name));
|
||||
if (string.IsNullOrEmpty(biosset.ReadString(Data.Models.Metadata.BiosSet.DescriptionKey)))
|
||||
missingFields.Add(Data.Models.Metadata.BiosSet.DescriptionKey);
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Description));
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
@@ -327,20 +327,20 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case DipSwitch dipswitch:
|
||||
if (string.IsNullOrEmpty(dipswitch.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipSwitch.Name));
|
||||
if (string.IsNullOrEmpty(dipswitch.ReadString(Data.Models.Metadata.DipSwitch.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.DipSwitch.TagKey);
|
||||
if (string.IsNullOrEmpty(dipswitch.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipSwitch.Tag));
|
||||
break;
|
||||
|
||||
case Configuration configuration:
|
||||
if (string.IsNullOrEmpty(configuration.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.Configuration.Name));
|
||||
if (string.IsNullOrEmpty(configuration.ReadString(Data.Models.Metadata.Configuration.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.Configuration.TagKey);
|
||||
if (string.IsNullOrEmpty(configuration.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.Configuration.Tag));
|
||||
break;
|
||||
|
||||
case Port port:
|
||||
if (string.IsNullOrEmpty(port.ReadString(Data.Models.Metadata.Port.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.Port.TagKey);
|
||||
if (string.IsNullOrEmpty(port.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.Port.Tag));
|
||||
break;
|
||||
|
||||
case Adjuster adjuster:
|
||||
@@ -375,8 +375,8 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case DatItems.Formats.SoftwareList softwarelist:
|
||||
if (string.IsNullOrEmpty(softwarelist.ReadString(Data.Models.Metadata.SoftwareList.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.TagKey);
|
||||
if (string.IsNullOrEmpty(softwarelist.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.SoftwareList.Tag));
|
||||
if (string.IsNullOrEmpty(softwarelist.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.SoftwareList.Name));
|
||||
if (softwarelist.Status == null)
|
||||
|
||||
@@ -275,8 +275,8 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrEmpty(biosset.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Name));
|
||||
if (string.IsNullOrEmpty(biosset.ReadString(Data.Models.Metadata.BiosSet.DescriptionKey)))
|
||||
missingFields.Add(Data.Models.Metadata.BiosSet.DescriptionKey);
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.BiosSet.Description));
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
@@ -354,8 +354,8 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case DatItems.Formats.SoftwareList softwarelist:
|
||||
if (string.IsNullOrEmpty(softwarelist.ReadString(Data.Models.Metadata.SoftwareList.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.TagKey);
|
||||
if (string.IsNullOrEmpty(softwarelist.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.SoftwareList.Tag));
|
||||
if (string.IsNullOrEmpty(softwarelist.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.SoftwareList.Name));
|
||||
if (softwarelist.Status == null)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
@@ -122,17 +122,17 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
|
||||
if (string.IsNullOrEmpty(dipSwitch.GetName()))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipSwitch.Name));
|
||||
if (string.IsNullOrEmpty(dipSwitch.ReadString(Data.Models.Metadata.DipSwitch.TagKey)))
|
||||
missingFields.Add(Data.Models.Metadata.DipSwitch.TagKey);
|
||||
if (string.IsNullOrEmpty(dipSwitch.ReadString(Data.Models.Metadata.DipSwitch.MaskKey)))
|
||||
missingFields.Add(Data.Models.Metadata.DipSwitch.MaskKey);
|
||||
if (string.IsNullOrEmpty(dipSwitch.Tag))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipSwitch.Tag));
|
||||
if (string.IsNullOrEmpty(dipSwitch.Mask))
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipSwitch.Mask));
|
||||
if (dipSwitch.ValuesSpecified)
|
||||
{
|
||||
var dipValues = dipSwitch.Read<DipValue[]?>(Data.Models.Metadata.DipSwitch.DipValueKey);
|
||||
if (Array.Find(dipValues!, dv => string.IsNullOrEmpty(dv.GetName())) is not null)
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipValue.Name));
|
||||
if (Array.Find(dipValues!, dv => string.IsNullOrEmpty(dv.ReadString(Data.Models.Metadata.DipValue.ValueKey))) is not null)
|
||||
missingFields.Add(Data.Models.Metadata.DipValue.ValueKey);
|
||||
if (Array.Find(dipValues!, dv => string.IsNullOrEmpty(dv.Value)) is not null)
|
||||
missingFields.Add(nameof(Data.Models.Metadata.DipValue.Value));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user