Handle null dictionaries

This commit is contained in:
Malte Rosenbjerg 2022-03-24 21:15:28 +01:00
parent c817381139
commit 1c851dc3ff

View file

@ -114,9 +114,9 @@ public static class MediaAnalysisUtils
{ {
private static readonly Regex DurationRegex = new Regex(@"^(\d+):(\d{1,2}):(\d{1,2})\.(\d{1,3})", RegexOptions.Compiled); private static readonly Regex DurationRegex = new Regex(@"^(\d+):(\d{1,2}):(\d{1,2})\.(\d{1,3})", RegexOptions.Compiled);
internal static Dictionary<string, string> ToCaseInsensitive(this Dictionary<string, string> dictionary) internal static Dictionary<string, string>? ToCaseInsensitive(this Dictionary<string, string>? dictionary)
{ {
return dictionary.ToDictionary(tag => tag.Key, tag => tag.Value, StringComparer.OrdinalIgnoreCase); return dictionary?.ToDictionary(tag => tag.Key, tag => tag.Value, StringComparer.OrdinalIgnoreCase) ?? new Dictionary<string, string>();
} }
public static double DivideRatio((double, double) ratio) => ratio.Item1 / ratio.Item2; public static double DivideRatio((double, double) ratio) => ratio.Item1 / ratio.Item2;