Using immuable collections in the file extensions class

This commit is contained in:
Zoe Roux 2021-07-21 19:41:25 +02:00
parent bb5dc0dcae
commit fd37cede9d
2 changed files with 5 additions and 4 deletions

View File

@ -32,6 +32,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<ProjectReference Include="../Kyoo.Common/Kyoo.Common.csproj" /> <ProjectReference Include="../Kyoo.Common/Kyoo.Common.csproj" />
<ProjectReference Include="../Kyoo.CommonAPI/Kyoo.CommonAPI.csproj" /> <ProjectReference Include="../Kyoo.CommonAPI/Kyoo.CommonAPI.csproj" />
<PackageReference Include="Autofac" Version="6.2.0" /> <PackageReference Include="Autofac" Version="6.2.0" />

View File

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO; using System.IO;
using System.Linq;
namespace Kyoo.Models.Watch namespace Kyoo.Models.Watch
{ {
@ -12,7 +12,7 @@ namespace Kyoo.Models.Watch
/// <summary> /// <summary>
/// The list of known video extensions /// The list of known video extensions
/// </summary> /// </summary>
public static readonly string[] VideoExtensions = public static readonly ImmutableArray<string> VideoExtensions = new()
{ {
".webm", ".webm",
".mkv", ".mkv",
@ -53,11 +53,11 @@ namespace Kyoo.Models.Watch
/// <summary> /// <summary>
/// The dictionary of known subtitles extensions and the name of the subtitle codec. /// The dictionary of known subtitles extensions and the name of the subtitle codec.
/// </summary> /// </summary>
public static readonly Dictionary<string, string> SubtitleExtensions = new() public static readonly ImmutableDictionary<string, string> SubtitleExtensions = new Dictionary<string, string>
{ {
{".ass", "ass"}, {".ass", "ass"},
{".str", "subrip"} {".str", "subrip"}
}; }.ToImmutableDictionary();
/// <summary> /// <summary>
/// Check if a file represent a subtitle file (only by checking the extension of the file) /// Check if a file represent a subtitle file (only by checking the extension of the file)