Added short switch usage with .net 5

This commit is contained in:
veysel mutlu 2021-09-10 21:16:44 +03:00
parent 9fda3b548c
commit d20232db12

View File

@ -56,40 +56,18 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
private string GetImageMimeTypeFromImageFileExtension(string extension)
{
string mimetype;
switch (extension)
string mimetype = extension switch
{
case ".png":
mimetype = "image/png";
break;
case ".gif":
mimetype = "image/gif";
break;
case ".jpg":
case ".jpeg":
mimetype = "image/jpeg";
break;
case ".bmp":
mimetype = "image/bmp";
break;
case ".tiff":
mimetype = "image/tiff";
break;
case ".wmf":
mimetype = "image/wmf";
break;
case ".jp2":
mimetype = "image/jp2";
break;
case ".svg":
mimetype = "image/svg+xml";
break;
default:
mimetype = "application/octet-stream";
break;
}
".png" => "image/png",
".gif" => "image/gif",
".jpg" or ".jpeg" => "image/jpeg",
".bmp" => "image/bmp",
".tiff" => "image/tiff",
".wmf" => "image/wmf",
".jp2" => "image/jp2",
".svg" => "image/svg+xml",
_ => "application/octet-stream",
};
return mimetype;
}
}