Gate some switch expressions

This commit is contained in:
Matt Nadareski
2023-10-12 01:19:47 -04:00
parent 83437977ba
commit ecee44966e
8 changed files with 318 additions and 51 deletions

View File

@@ -1951,6 +1951,7 @@ namespace MPF.Core.Modules
/// <returns>Category, if possible</returns>
protected static DiscCategory? GetUMDCategory(string category)
{
#if NET48
switch (category)
{
case "GAME": return DiscCategory.Games;
@@ -1958,6 +1959,15 @@ namespace MPF.Core.Modules
case "AUDIO": return DiscCategory.Audio;
default: return null;
}
#else
return category switch
{
"GAME" => DiscCategory.Games,
"VIDEO" => DiscCategory.Video,
"AUDIO" => DiscCategory.Audio,
_ => null,
};
#endif
}
#endregion
@@ -1989,16 +1999,28 @@ namespace MPF.Core.Modules
{
case 'S':
// Check first two digits of S_PS serial
#if NET48
switch (serial.Substring(5, 2))
{
case "46": return Region.SouthKorea;
case "56": return Region.SouthKorea;
case "51": return Region.Asia;
case "56": return Region.SouthKorea;
case "55": return Region.Asia;
default: return Region.Japan;
}
#else
return serial.Substring(5, 2) switch
{
"46" => Region.SouthKorea,
"51" => Region.Asia,
"56" => Region.SouthKorea,
"55" => Region.Asia,
_ => Region.Japan,
};
#endif
case 'M':
// Check first three digits of S_PM serial
#if NET48
switch (serial.Substring(5, 3))
{
case "645": return Region.SouthKorea;
@@ -2006,6 +2028,15 @@ namespace MPF.Core.Modules
case "885": return Region.SouthKorea;
default: return Region.Japan; // Remaining S_PM serials may be Japan or Asia
}
#else
return serial.Substring(5, 3) switch
{
"645" => Region.SouthKorea,
"675" => Region.SouthKorea,
"885" => Region.SouthKorea,
_ => Region.Japan, // Remaining S_PM serials may be Japan or Asia
};
#endif
default: return Region.Japan;
}
}