More pattern matching.

This commit is contained in:
2022-11-14 01:49:10 +00:00
parent 8a511d0d44
commit 040b4eab4e
18 changed files with 33 additions and 57 deletions

View File

@@ -184,7 +184,7 @@ public sealed class ImageInfoViewModel : ViewModelBase
imageFormat.Info.Heads > 0 &&
imageFormat.Info.SectorsPerTrack > 0 &&
imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
(imageFormat is not ITapeImage tapeImage || !tapeImage.IsTape))
imageFormat is not ITapeImage { IsTape: true })
MediaGeometryText =
$"Media geometry: {imageFormat.Info.Cylinders} cylinders, {imageFormat.Info.Heads} heads, {imageFormat.Info.SectorsPerTrack} sectors per track";

View File

@@ -522,9 +522,7 @@ public sealed class MainWindowViewModel : ViewModelBase
try
{
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
if(imageFormat == null)
if(ImageFormat.Detect(inputFilter) is not IMediaImage imageFormat)
{
MessageBoxManager.GetMessageBoxStandardWindow("Error", "Image format not identified.", ButtonEnum.Ok,
Icon.Error);