mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Reduce Linq usage across entire project
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.DatItems;
|
||||
@@ -126,7 +125,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
// Resolve the names in the block
|
||||
items = DatItem.ResolveNamesDB(items.ToConcurrentList()).ToArray();
|
||||
items = [.. DatItem.ResolveNamesDB(items.ToConcurrentList())];
|
||||
|
||||
for (int index = 0; index < items.Length; index++)
|
||||
{
|
||||
|
||||
@@ -113,11 +113,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Read in the machine array
|
||||
jtr.Read();
|
||||
JsonSerializer js = new();
|
||||
JArray? machineArray = js.Deserialize<JArray>(jtr);
|
||||
var js = new JsonSerializer();
|
||||
JArray machineArray = js.Deserialize<JArray>(jtr) ?? [];
|
||||
|
||||
// Loop through each machine object and process
|
||||
foreach (JObject machineObj in (machineArray ?? []).Cast<JObject>())
|
||||
foreach (JObject machineObj in machineArray)
|
||||
{
|
||||
ReadMachine(machineObj, statsOnly, source, sourceIndex);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return;
|
||||
|
||||
// Loop through each datitem object and process
|
||||
foreach (JObject itemObj in itemsArr.Cast<JObject>())
|
||||
foreach (JObject itemObj in itemsArr)
|
||||
{
|
||||
ReadItem(itemObj, statsOnly, source, sourceIndex, machine, machineIndex);
|
||||
}
|
||||
@@ -480,7 +480,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
// Resolve the names in the block
|
||||
items = DatItem.ResolveNamesDB(items.ToConcurrentList()).ToArray();
|
||||
items = [.. DatItem.ResolveNamesDB(items.ToConcurrentList())];
|
||||
|
||||
for (int index = 0; index < items.Length; index++)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
@@ -310,7 +309,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
continue;
|
||||
|
||||
// Resolve the names in the block
|
||||
items = DatItem.ResolveNamesDB(items.ToConcurrentList()).ToArray();
|
||||
items = [.. DatItem.ResolveNamesDB(items.ToConcurrentList())];
|
||||
|
||||
for (int index = 0; index < items.Length; index++)
|
||||
{
|
||||
|
||||
@@ -122,9 +122,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
missingFields.Add(Models.Metadata.DipSwitch.MaskKey);
|
||||
if (dipSwitch.ValuesSpecified)
|
||||
{
|
||||
if (dipSwitch.GetFieldValue<DipValue[]?>(Models.Metadata.DipSwitch.DipValueKey)!.Any(dv => string.IsNullOrEmpty(dv.GetName())))
|
||||
var dipValues = dipSwitch.GetFieldValue<DipValue[]?>(Models.Metadata.DipSwitch.DipValueKey);
|
||||
if (dipValues!.Any(dv => string.IsNullOrEmpty(dv.GetName())))
|
||||
missingFields.Add(Models.Metadata.DipValue.NameKey);
|
||||
if (dipSwitch.GetFieldValue<DipValue[]?>(Models.Metadata.DipSwitch.DipValueKey)!.Any(dv => string.IsNullOrEmpty(dv.GetStringFieldValue(Models.Metadata.DipValue.ValueKey))))
|
||||
if (dipValues!.Any(dv => string.IsNullOrEmpty(dv.GetStringFieldValue(Models.Metadata.DipValue.ValueKey))))
|
||||
missingFields.Add(Models.Metadata.DipValue.ValueKey);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user