From 6561d0bec10b362227e81a7de6c88bd66d0346be Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Thu, 27 Feb 2020 20:24:20 +0100 Subject: [PATCH] Use switch expression --- FFMpegCore/Enums/FileExtension.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/FFMpegCore/Enums/FileExtension.cs b/FFMpegCore/Enums/FileExtension.cs index 212e3db..e92fbe9 100644 --- a/FFMpegCore/Enums/FileExtension.cs +++ b/FFMpegCore/Enums/FileExtension.cs @@ -7,26 +7,26 @@ public static class FileExtension { public static string ForType(VideoType type) { - switch (type) + return type switch { - case VideoType.Mp4: return Mp4; - case VideoType.Ogv: return Ogv; - case VideoType.Ts: return Ts; - case VideoType.WebM: return WebM; - default: throw new Exception("The extension for this video type is not defined."); - } + VideoType.Mp4 => Mp4, + VideoType.Ogv => Ogv, + VideoType.Ts => Ts, + VideoType.WebM => WebM, + _ => throw new Exception("The extension for this video type is not defined.") + }; } public static string ForCodec(VideoCodec type) { - switch (type) + return type switch { - case VideoCodec.LibX264: return Mp4; - case VideoCodec.LibVpx: return WebM; - case VideoCodec.LibTheora: return Ogv; - case VideoCodec.MpegTs: return Ts; - case VideoCodec.Png: return Png; - default: throw new Exception("The extension for this video type is not defined."); - } + VideoCodec.LibX264 => Mp4, + VideoCodec.LibVpx => WebM, + VideoCodec.LibTheora => Ogv, + VideoCodec.MpegTs => Ts, + VideoCodec.Png => Png, + _ => throw new Exception("The extension for this video type is not defined.") + }; } public static readonly string Mp4 = ".mp4"; public static readonly string Mp3 = ".mp3";