mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Be smarter about some data types
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
- Update Redumper to build 438
|
||||
- Be smarter about Linq usage
|
||||
- Add .NET 9 to target frameworks
|
||||
- Be smarter about some data types
|
||||
|
||||
### 3.2.3 (2024-11-06)
|
||||
|
||||
|
||||
@@ -1292,7 +1292,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
for (start = 0; start < parts.Count; start++)
|
||||
{
|
||||
// Keep a count of keys to determine if we should break out to command handling or not
|
||||
int keyCount = Keys.Count();
|
||||
int keyCount = Keys.Count;
|
||||
|
||||
// Debug
|
||||
ProcessBooleanParameter(parts, FlagStrings.DebugShort, FlagStrings.DebugLong, ref start, true);
|
||||
@@ -1311,7 +1311,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
ProcessBooleanParameter(parts, FlagStrings.HelpShortAlt, FlagStrings.HelpLong, ref start, true);
|
||||
|
||||
// If we didn't add any new flags, break out since we might be at command handling
|
||||
if (keyCount == Keys.Count())
|
||||
if (keyCount == Keys.Count)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1339,7 +1339,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
string? stringValue = null;
|
||||
|
||||
// Keep a count of keys to determine if we should break out to filename handling or not
|
||||
int keyCount = Keys.Count();
|
||||
int keyCount = Keys.Count;
|
||||
|
||||
#region Boolean flags
|
||||
|
||||
@@ -1706,7 +1706,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
#endregion
|
||||
|
||||
// If we didn't add any new flags, break out since we might be at filename handling
|
||||
if (keyCount == Keys.Count())
|
||||
if (keyCount == Keys.Count)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.ExecutionContexts
|
||||
@@ -20,7 +19,7 @@ namespace MPF.ExecutionContexts
|
||||
/// Set of flags to pass to the executable
|
||||
/// </summary>
|
||||
protected Dictionary<string, bool?> flags = [];
|
||||
protected internal IEnumerable<string> Keys => flags.Keys;
|
||||
protected internal List<string> Keys => [.. flags.Keys];
|
||||
|
||||
/// <summary>
|
||||
/// Safe access to currently set flags
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MPF.Frontend.ComboBoxItems
|
||||
{
|
||||
@@ -42,9 +41,8 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Element<T>> GenerateElements()
|
||||
{
|
||||
return Enum.GetValues(typeof(T))
|
||||
.OfType<T>()
|
||||
.Select(e => new Element<T>(e));
|
||||
var enumArr = (T[])Enum.GetValues(typeof(T));
|
||||
return Array.ConvertAll(enumArr, e => new Element<T>(e));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<RedumpSystemComboBoxItem> GenerateElements()
|
||||
{
|
||||
var knownSystems = Enum.GetValues(typeof(RedumpSystem))
|
||||
.OfType<RedumpSystem?>()
|
||||
.Where(s => !s.IsMarker() && s.GetCategory() != SystemCategory.NONE)
|
||||
.ToList();
|
||||
var enumArr = (RedumpSystem[])Enum.GetValues(typeof(RedumpSystem));
|
||||
var nullableArr = Array.ConvertAll(enumArr, s => (RedumpSystem?)s);
|
||||
var knownSystems = Array.FindAll(nullableArr,
|
||||
s => !s.IsMarker() && s.GetCategory() != SystemCategory.NONE);
|
||||
|
||||
Dictionary<SystemCategory, List<RedumpSystem?>> mapping = knownSystems
|
||||
.GroupBy(s => s.GetCategory())
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
using Microsoft.Management.Infrastructure;
|
||||
using Microsoft.Management.Infrastructure.Generic;
|
||||
@@ -137,8 +136,13 @@ namespace MPF.Frontend
|
||||
public static List<Drive> CreateListOfDrives(bool ignoreFixedDrives)
|
||||
{
|
||||
var drives = GetDriveList(ignoreFixedDrives);
|
||||
drives = [.. drives.OrderBy(i => i == null ? "\0" : i.Name)];
|
||||
return drives;
|
||||
drives.Sort((d1, d2) =>
|
||||
{
|
||||
string d1Name = d1?.Name == null ? "\0" : d1.Name;
|
||||
string d2Name = d2?.Name == null ? "\0" : d2.Name;
|
||||
return d1Name.CompareTo(d2Name);
|
||||
});
|
||||
return [.. drives];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BinaryObjectScanner;
|
||||
using MPF.Frontend.ComboBoxItems;
|
||||
using MPF.Frontend.Tools;
|
||||
using SabreTools.IO;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Frontend.ViewModels
|
||||
@@ -708,10 +708,9 @@ namespace MPF.Frontend.ViewModels
|
||||
DisableEventHandlers();
|
||||
|
||||
// Create a static list of supported programs, not everything
|
||||
InternalPrograms = Enum.GetValues(typeof(InternalProgram))
|
||||
.Cast<InternalProgram>()
|
||||
.Where(ip => InternalProgramExists(ip))
|
||||
.Select(ip => new Element<InternalProgram>(ip)).ToList();
|
||||
var ipArr = (InternalProgram[])Enum.GetValues(typeof(InternalProgram));
|
||||
ipArr = Array.FindAll(ipArr, ip => InternalProgramExists(ip));
|
||||
InternalPrograms = [.. Array.ConvertAll(ipArr, ip => new Element<InternalProgram>(ip))];
|
||||
|
||||
// Get the current internal program
|
||||
InternalProgram internalProgram = Options.InternalProgram;
|
||||
@@ -1556,11 +1555,7 @@ namespace MPF.Frontend.ViewModels
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drive.Name, "$SystemUpdate"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "$SystemUpdate")).Any()
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "$SystemUpdate")).Any()
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "$SystemUpdate")).Length > 0
|
||||
&& drive.TotalSize <= 500_000_000)
|
||||
{
|
||||
return RedumpSystem.MicrosoftXbox360;
|
||||
@@ -1712,21 +1707,13 @@ namespace MPF.Frontend.ViewModels
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drive.Name, "AUDIO_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "AUDIO_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "AUDIO_TS")).Any())
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "AUDIO_TS")).Length > 0)
|
||||
{
|
||||
return RedumpSystem.DVDAudio;
|
||||
}
|
||||
|
||||
else if (Directory.Exists(Path.Combine(drive.Name, "VIDEO_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "VIDEO_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "VIDEO_TS")).Any())
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "VIDEO_TS")).Length > 0)
|
||||
{
|
||||
return RedumpSystem.DVDVideo;
|
||||
}
|
||||
@@ -1737,11 +1724,7 @@ namespace MPF.Frontend.ViewModels
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drive.Name, "HVDVD_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "HVDVD_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "HVDVD_TS")).Any())
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "HVDVD_TS")).Length > 0)
|
||||
{
|
||||
return RedumpSystem.HDDVDVideo;
|
||||
}
|
||||
@@ -1752,11 +1735,7 @@ namespace MPF.Frontend.ViewModels
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drive.Name, "PHOTO_CD"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "PHOTO_CD")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "PHOTO_CD")).Any())
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "PHOTO_CD")).Length > 0)
|
||||
{
|
||||
return RedumpSystem.PhotoCD;
|
||||
}
|
||||
@@ -1767,11 +1746,7 @@ namespace MPF.Frontend.ViewModels
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drive.Name, "VCD"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(drive.Name, "drive.VCD")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "VCD")).Any())
|
||||
#endif
|
||||
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "VCD")).Length > 0)
|
||||
{
|
||||
return RedumpSystem.VideoCD;
|
||||
}
|
||||
|
||||
@@ -1316,7 +1316,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// If we have all Session 1, we can just skip out
|
||||
if (trackSessionMapping.All(kvp => kvp.Value == "1"))
|
||||
if (trackSessionMapping.Values.All(v => v == "1"))
|
||||
return null;
|
||||
|
||||
// Seek to the multisession data
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace MPF.Processors
|
||||
var archiveFiles = archive.Entries.Select(e => e.Name).ToList();
|
||||
foreach (string file in archiveFiles)
|
||||
{
|
||||
if (Filenames.Any(pattern => Regex.IsMatch(file, pattern)))
|
||||
if (Array.Exists(Filenames, pattern => Regex.IsMatch(file, pattern)))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user