mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Version gate remaining Linq statements
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
- Improve parameters for default output path
|
||||
- Replace some uses of Regex.Replace
|
||||
- Clean up usings after last commit
|
||||
- Version gate remaining Linq statements
|
||||
|
||||
### 3.2.3 (2024-11-06)
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Frontend.ComboBoxItems
|
||||
@@ -57,6 +59,19 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
var knownSystems = Array.FindAll(nullableArr,
|
||||
s => !s.IsMarker() && s.GetCategory() != SystemCategory.NONE);
|
||||
|
||||
#if NET20
|
||||
// The resulting dictionary does not have ordered value lists
|
||||
var mapping = new Dictionary<SystemCategory, List<RedumpSystem?>>();
|
||||
foreach (var knownSystem in knownSystems)
|
||||
{
|
||||
var category = knownSystem.GetCategory();
|
||||
if (!mapping.ContainsKey(category))
|
||||
mapping[category] = [];
|
||||
|
||||
mapping[category].Add(knownSystem);
|
||||
}
|
||||
#else
|
||||
// The resulting dictionary has ordered value lists
|
||||
Dictionary<SystemCategory, List<RedumpSystem?>> mapping = knownSystems
|
||||
.GroupBy(s => s.GetCategory())
|
||||
.ToDictionary(
|
||||
@@ -65,6 +80,7 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
.OrderBy(s => s.LongName())
|
||||
.ToList()
|
||||
);
|
||||
#endif
|
||||
|
||||
var systemsValues = new List<RedumpSystemComboBoxItem>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using BinaryObjectScanner;
|
||||
@@ -64,11 +66,26 @@ namespace MPF.Frontend.Tools
|
||||
else if (protections.Count == 0)
|
||||
return "None found [OMIT FROM SUBMISSION]";
|
||||
|
||||
// Get an ordered list of distinct found protections
|
||||
// Get a list of distinct found protections
|
||||
#if NET20
|
||||
var protectionValues = new List<string>();
|
||||
foreach (var value in protections.Values)
|
||||
{
|
||||
if (value.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var prot in value)
|
||||
{
|
||||
if (!protectionValues.Contains(prot))
|
||||
protectionValues.Add(prot);
|
||||
}
|
||||
}
|
||||
#else
|
||||
var protectionValues = protections
|
||||
.SelectMany(kvp => kvp.Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
#endif
|
||||
|
||||
// Sanitize and join protections for writing
|
||||
string protectionString = SanitizeFoundProtections(protectionValues);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Threading.Tasks;
|
||||
using BinaryObjectScanner;
|
||||
using MPF.Processors;
|
||||
@@ -416,7 +418,13 @@ namespace MPF.Frontend.Tools
|
||||
}
|
||||
|
||||
// If only one label, don't mention fs
|
||||
#if NET20
|
||||
string[] keyArr = new string[labels.Count];
|
||||
labels.Keys.CopyTo(keyArr, 0);
|
||||
string firstLabel = keyArr[0];
|
||||
#else
|
||||
string firstLabel = labels.First().Key;
|
||||
#endif
|
||||
if (labels.Count == 1 && (firstLabel == driveLabel || driveLabel == null))
|
||||
{
|
||||
// Ignore common volume labels
|
||||
|
||||
@@ -4,7 +4,9 @@ using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.IO.Compression;
|
||||
#endif
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
@@ -414,7 +416,17 @@ namespace MPF.Processors
|
||||
|
||||
// Filter down to deleteable files
|
||||
var deleteableFiles = outputFiles.FindAll(of => of.IsDeleteable);
|
||||
#if NET20
|
||||
var deleteableFilenames = new List<string>();
|
||||
foreach (var deleteableFile in deleteableFiles)
|
||||
{
|
||||
deleteableFilenames.AddRange(deleteableFile.Filenames);
|
||||
}
|
||||
|
||||
return deleteableFilenames;
|
||||
#else
|
||||
return deleteableFiles.SelectMany(of => of.Filenames).ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -519,7 +531,17 @@ namespace MPF.Processors
|
||||
|
||||
// Filter down to zippable files
|
||||
var zippableFiles = outputFiles.FindAll(of => of.IsZippable);
|
||||
#if NET20
|
||||
var zippableFilenames = new List<string>();
|
||||
foreach (var zippableFile in zippableFiles)
|
||||
{
|
||||
zippableFilenames.AddRange(zippableFile.Filenames);
|
||||
}
|
||||
|
||||
return zippableFilenames;
|
||||
#else
|
||||
return zippableFiles.SelectMany(of => of.Filenames).ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -664,7 +686,7 @@ namespace MPF.Processors
|
||||
sb.Append(line);
|
||||
sb.Append('\n');
|
||||
}
|
||||
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text.RegularExpressions;
|
||||
using psxt001z;
|
||||
using SabreTools.Models.Logiqx;
|
||||
@@ -1931,10 +1933,23 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// Deduplicate the offsets
|
||||
#if NET20
|
||||
var temp = new List<string>();
|
||||
foreach (var offset in offsets)
|
||||
{
|
||||
if (offset == null || offset.Length == 0)
|
||||
continue;
|
||||
if (!temp.Contains(offset))
|
||||
temp.Add(offset);
|
||||
}
|
||||
|
||||
offsets = temp;
|
||||
#else
|
||||
offsets = offsets
|
||||
.FindAll(s => !string.IsNullOrEmpty(s))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
#endif
|
||||
|
||||
// Now that we're at the offsets, attempt to get the sample offset
|
||||
return string.Join("; ", [.. offsets]);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
@@ -919,7 +921,13 @@ namespace MPF.Processors
|
||||
if (!GetXGDType(ss, out int xgdType))
|
||||
return false;
|
||||
|
||||
#if NET20
|
||||
var checkArr = new byte[72];
|
||||
Array.Copy(ss, 32, checkArr, 0, 72);
|
||||
if (xgdType == 3 && Array.TrueForAll(checkArr, x => x == 0))
|
||||
#else
|
||||
if (xgdType == 3 && ss.Skip(32).Take(72).All(x => x == 0))
|
||||
#endif
|
||||
{
|
||||
// Check for a cleaned SSv2
|
||||
|
||||
@@ -1071,7 +1079,13 @@ namespace MPF.Processors
|
||||
|
||||
case 3:
|
||||
// Determine if XGD3 SS.bin is SSv1 (Kreon) or SSv2 (0800)
|
||||
#if NET20
|
||||
var checkArr = new byte[72];
|
||||
Array.Copy(ss, 32, checkArr, 0, 72);
|
||||
bool ssv2 = !Array.TrueForAll(checkArr, x => x == 0);
|
||||
#else
|
||||
bool ssv2 = ss.Skip(32).Take(72).Any(x => x != 0);
|
||||
#endif
|
||||
|
||||
if (ssv2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user