From fde1c9609dcf6ebbdd8ad8f7e4320c266ceb32b5 Mon Sep 17 00:00:00 2001 From: jbe2277 Date: Sat, 25 Nov 2023 13:50:25 +0100 Subject: [PATCH] Remove Windows version check from SupportedFileTypes; Win10 is minimum required --- .../Services/SupportedFileTypes.cs | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs b/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs index f9d0fb4..42d4c4a 100644 --- a/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs +++ b/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs @@ -5,8 +5,6 @@ namespace Waf.MusicManager.Presentation.Services; internal static class SupportedFileTypes { - private static readonly string[] musicFileExtensions = [ ".mp3", ".wma", ".wav", ".m4a", ".mp4" ]; - private static readonly Mp3ReadMetadata mp3ReadMetadata = new(); private static readonly WmaReadMetadata wmaReadMetadata = new(); private static readonly AacReadMetadata aacReadMetadata = new(); @@ -23,14 +21,10 @@ internal static class SupportedFileTypes private static readonly FlacSaveMetadata flacSaveMetadata = new(); private static readonly MkvSaveMetadata mkvSaveMetadata = new(); - public static IReadOnlyList MusicFileExtensions => AddMoreExtensionsWhenSupported(musicFileExtensions); + public static IReadOnlyList MusicFileExtensions => [".mp3", ".wma", ".wav", ".m4a", ".mp4", ".flac", ".mkv"]; public static IReadOnlyList PlaylistFileExtensions => IFileService.PlaylistFileExtensions; - private static bool IsFlacSupported => Environment.OSVersion.Version.Major >= 10; - - private static bool IsMkvSupported => Environment.OSVersion.Version.Major >= 10; - internal static ReadMetadata GetReadMetadata(string fileExtension) { if (fileExtension.Equals(".mp3", StringComparison.OrdinalIgnoreCase)) @@ -53,11 +47,11 @@ internal static ReadMetadata GetReadMetadata(string fileExtension) { return mp4ReadMetadata; } - else if (IsFlacSupported && fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase)) + else if (fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase)) { return flacReadMetadata; } - else if (IsMkvSupported && fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase)) + else if (fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase)) { return mkvReadMetadata; } @@ -89,11 +83,11 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension) { return mp4SaveMetadata; } - else if (IsFlacSupported && fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase)) + else if (fileExtension.Equals(".flac", StringComparison.OrdinalIgnoreCase)) { return flacSaveMetadata; } - else if (IsMkvSupported && fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase)) + else if (fileExtension.Equals(".mkv", StringComparison.OrdinalIgnoreCase)) { return mkvSaveMetadata; } @@ -102,12 +96,4 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension) throw new NotSupportedException("The provided extension '" + fileExtension + "' is not supported."); } } - - private static IReadOnlyList AddMoreExtensionsWhenSupported(IReadOnlyList extensions) - { - IEnumerable result = extensions; - if (IsFlacSupported) result = result.Concat([ ".flac" ]); - if (IsMkvSupported) result = result.Concat([ ".mkv" ]); - return result.ToArray(); - } }