mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Found out why these helpers were this way
This commit is contained in:
@@ -121,7 +121,7 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
|
||||
datFile.MachineDescriptionToName();
|
||||
|
||||
Machine actualMachine = Assert.Single(datFile.GetMachinesDB());
|
||||
Machine actualMachine = Assert.Single(datFile.GetMachinesDB()).Value;
|
||||
Assert.Equal("description", actualMachine.Name);
|
||||
Assert.Equal("description", actualMachine.Description);
|
||||
}
|
||||
@@ -274,7 +274,7 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
List<string> regions = ["World", "Nowhere"];
|
||||
datFile.SetOneGamePerRegion(regions);
|
||||
|
||||
var actualWorldMachine = Assert.Single(datFile.GetMachinesDB());
|
||||
var actualWorldMachine = Assert.Single(datFile.GetMachinesDB()).Value;
|
||||
Assert.NotNull(actualWorldMachine);
|
||||
Assert.Equal("machine (World)", actualWorldMachine.Name);
|
||||
}
|
||||
@@ -318,7 +318,7 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
|
||||
datFile.StripSceneDatesFromItems();
|
||||
|
||||
Machine actualMachine = Assert.Single(datFile.GetMachinesDB());
|
||||
Machine actualMachine = Assert.Single(datFile.GetMachinesDB()).Value;
|
||||
Assert.Equal("machine-name", actualMachine.Name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ namespace SabreTools.Metadata.DatFiles.Test
|
||||
datFile.BucketBy(ItemKey.Machine);
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
|
||||
Machine actual = Assert.Single(datFile.GetMachinesDB());
|
||||
Machine actual = Assert.Single(datFile.GetMachinesDB()).Value;
|
||||
Assert.Null(actual.CloneOf);
|
||||
Assert.Null(actual.RomOf);
|
||||
Assert.Null(actual.SampleOf);
|
||||
|
||||
@@ -161,8 +161,8 @@ namespace SabreTools.Metadata.DatFiles
|
||||
foreach (var machine in GetMachinesDB())
|
||||
{
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Name;
|
||||
string? machineDesc = machine.Description;
|
||||
string? machineName = machine.Value.Name;
|
||||
string? machineDesc = machine.Value.Description;
|
||||
if (machineName is null || machineDesc is null)
|
||||
continue;
|
||||
|
||||
@@ -398,13 +398,13 @@ namespace SabreTools.Metadata.DatFiles
|
||||
foreach (var machine in GetMachinesDB())
|
||||
{
|
||||
// Get machine information
|
||||
string? machineName = machine.Name?.ToLowerInvariant();
|
||||
if (machine is null || machineName is null)
|
||||
string? machineName = machine.Value?.Name?.ToLowerInvariant();
|
||||
if (machine.Value is null || machineName is null)
|
||||
continue;
|
||||
|
||||
// Get the string values
|
||||
string? cloneOf = machine.CloneOf?.ToLowerInvariant();
|
||||
string? romOf = machine.RomOf?.ToLowerInvariant();
|
||||
string? cloneOf = machine.Value.CloneOf?.ToLowerInvariant();
|
||||
string? romOf = machine.Value.RomOf?.ToLowerInvariant();
|
||||
|
||||
// Match on CloneOf first
|
||||
if (!string.IsNullOrEmpty(cloneOf))
|
||||
@@ -675,15 +675,15 @@ namespace SabreTools.Metadata.DatFiles
|
||||
#endif
|
||||
{
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Name;
|
||||
string? machineDesc = machine.Description;
|
||||
string? machineName = machine.Value.Name;
|
||||
string? machineDesc = machine.Value.Description;
|
||||
|
||||
#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'
|
||||
if (machineName is not null && Regex.IsMatch(machineName, SceneNamePattern))
|
||||
machine.Name = Regex.Replace(machineName, SceneNamePattern, "$2");
|
||||
machine.Value.Name = Regex.Replace(machineName, SceneNamePattern, "$2");
|
||||
|
||||
if (machineDesc is not null && Regex.IsMatch(machineDesc, SceneNamePattern))
|
||||
machine.Description = Regex.Replace(machineDesc, SceneNamePattern, "$2");
|
||||
machine.Value.Description = Regex.Replace(machineDesc, SceneNamePattern, "$2");
|
||||
#pragma warning restore SYSLIB1045
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
});
|
||||
@@ -757,26 +757,26 @@ namespace SabreTools.Metadata.DatFiles
|
||||
foreach (var machine in GetMachinesDB())
|
||||
{
|
||||
// Get the values to check against
|
||||
string? machineName = machine.Name;
|
||||
string? cloneOf = machine.CloneOf;
|
||||
string? romOf = machine.RomOf;
|
||||
string? sampleOf = machine.SampleOf;
|
||||
string? machineName = machine.Value.Name;
|
||||
string? cloneOf = machine.Value.CloneOf;
|
||||
string? romOf = machine.Value.RomOf;
|
||||
string? sampleOf = machine.Value.SampleOf;
|
||||
|
||||
// Update machine name
|
||||
if (machineName is not null && mapping.TryGetValue(machineName, out string? mappedMachineName))
|
||||
machine.Name = mappedMachineName;
|
||||
machine.Value.Name = mappedMachineName;
|
||||
|
||||
// Update cloneof
|
||||
if (cloneOf is not null && mapping.TryGetValue(cloneOf, out string? mappedCloneOf))
|
||||
machine.CloneOf = mappedCloneOf;
|
||||
machine.Value.CloneOf = mappedCloneOf;
|
||||
|
||||
// Update romof
|
||||
if (romOf is not null && mapping.TryGetValue(romOf, out string? mappedRomOf))
|
||||
machine.RomOf = mappedRomOf;
|
||||
machine.Value.RomOf = mappedRomOf;
|
||||
|
||||
// Update sampleof
|
||||
if (sampleOf is not null && mapping.TryGetValue(sampleOf, out string? mappedSampleOf))
|
||||
machine.SampleOf = mappedSampleOf;
|
||||
machine.Value.SampleOf = mappedSampleOf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1421,9 +1421,9 @@ namespace SabreTools.Metadata.DatFiles
|
||||
foreach (var machine in machines)
|
||||
#endif
|
||||
{
|
||||
machine.CloneOf = null;
|
||||
machine.RomOf = null;
|
||||
machine.SampleOf = null;
|
||||
machine.Value.CloneOf = null;
|
||||
machine.Value.RomOf = null;
|
||||
machine.Value.SampleOf = null;
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
});
|
||||
#else
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <summary>
|
||||
/// Get all machines and their indicies
|
||||
/// </summary>
|
||||
public Machine[] GetMachinesDB()
|
||||
public IDictionary<long, Machine> GetMachinesDB()
|
||||
=> ItemsDB.GetMachines();
|
||||
|
||||
/// <summary>
|
||||
@@ -283,6 +283,12 @@ namespace SabreTools.Metadata.DatFiles
|
||||
public KeyValuePair<long, Source?> GetSourceDB(long sourceIndex)
|
||||
=> ItemsDB.GetSource(sourceIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Get all sources and their indicies
|
||||
/// </summary>
|
||||
public IDictionary<long, Source> GetSourcesDB()
|
||||
=> ItemsDB.GetSources();
|
||||
|
||||
/// <summary>
|
||||
/// Remove a key from the file dictionary if it exists
|
||||
/// </summary>
|
||||
|
||||
@@ -535,6 +535,12 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// </summary>
|
||||
public DatItem? GetItem(long index) => _items.Get(index);
|
||||
|
||||
/// <summary>
|
||||
/// Get the internal item table
|
||||
/// </summary>
|
||||
/// TODO: Figure out if this can be removed
|
||||
public IDictionary<long, DatItem> GetItems() => _items.Table;
|
||||
|
||||
/// <summary>
|
||||
/// Get the indices and items associated with a bucket name
|
||||
/// </summary>
|
||||
@@ -584,9 +590,10 @@ namespace SabreTools.Metadata.DatFiles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all machines and their indicies
|
||||
/// Get the internal machine table
|
||||
/// </summary>
|
||||
public Machine[] GetMachines() => _machines.Values;
|
||||
/// TODO: Figure out if this can be removed
|
||||
public IDictionary<long, Machine> GetMachines() => _machines.Table;
|
||||
|
||||
/// <summary>
|
||||
/// Get a source based on the index
|
||||
@@ -599,6 +606,12 @@ namespace SabreTools.Metadata.DatFiles
|
||||
return new KeyValuePair<long, Source?>(index, source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the internal source table
|
||||
/// </summary>
|
||||
/// TODO: Figure out if this can be removed
|
||||
public IDictionary<long, Source> GetSources() => _sources.Table;
|
||||
|
||||
/// <summary>
|
||||
/// Remove a key from the file dictionary if it exists
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user