Use switch expression

This commit is contained in:
Malte Rosenbjerg 2020-02-27 20:24:20 +01:00
parent 0e2c788796
commit 6561d0bec1

View file

@ -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";