Use switch expression

Former-commit-id: 6561d0bec1
This commit is contained in:
Malte Rosenbjerg 2020-02-27 20:24:20 +01:00
parent 7d77c33609
commit ff1c7e070b

View file

@ -7,26 +7,26 @@ public static class FileExtension
{ {
public static string ForType(VideoType type) public static string ForType(VideoType type)
{ {
switch (type) return type switch
{ {
case VideoType.Mp4: return Mp4; VideoType.Mp4 => Mp4,
case VideoType.Ogv: return Ogv; VideoType.Ogv => Ogv,
case VideoType.Ts: return Ts; VideoType.Ts => Ts,
case VideoType.WebM: return WebM; VideoType.WebM => WebM,
default: throw new Exception("The extension for this video type is not defined."); _ => throw new Exception("The extension for this video type is not defined.")
} };
} }
public static string ForCodec(VideoCodec type) public static string ForCodec(VideoCodec type)
{ {
switch (type) return type switch
{ {
case VideoCodec.LibX264: return Mp4; VideoCodec.LibX264 => Mp4,
case VideoCodec.LibVpx: return WebM; VideoCodec.LibVpx => WebM,
case VideoCodec.LibTheora: return Ogv; VideoCodec.LibTheora => Ogv,
case VideoCodec.MpegTs: return Ts; VideoCodec.MpegTs => Ts,
case VideoCodec.Png: return Png; VideoCodec.Png => Png,
default: throw new Exception("The extension for this video type is not defined."); _ => throw new Exception("The extension for this video type is not defined.")
} };
} }
public static readonly string Mp4 = ".mp4"; public static readonly string Mp4 = ".mp4";
public static readonly string Mp3 = ".mp3"; public static readonly string Mp3 = ".mp3";