Merge negated null/pattern checks into complex pattern.

This commit is contained in:
2024-11-12 06:18:24 +00:00
parent 3074e76932
commit 11bc15f1dd
2 changed files with 23 additions and 11 deletions

View File

@@ -370,7 +370,7 @@ public class Winfsp : FileSystemBase
{
bytesTransferred = 0;
if(fileNode is not FileNode node || node.Handle <= 0) return STATUS_INVALID_HANDLE;
if(fileNode is not FileNode { Handle: > 0 } node) return STATUS_INVALID_HANDLE;
var buf = new byte[length];
@@ -402,7 +402,7 @@ public class Winfsp : FileSystemBase
fileName = default(string);
fileInfo = default(FileInfo);
if(fileNode is not FileNode node || !node.IsDirectory) return false;
if(fileNode is not FileNode { IsDirectory: true } node) return false;
if(context is not IEnumerator<FileEntry> enumerator)
{

View File

@@ -80,9 +80,13 @@ public class App : Application
void OnAboutClicked(object sender, EventArgs args)
{
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow is not MainWindow mainWindow ||
mainWindow.DataContext is not MainWindowViewModel mainWindowViewModel)
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime
{
MainWindow: MainWindow
{
DataContext: MainWindowViewModel mainWindowViewModel
}
})
return;
mainWindowViewModel.ExecuteAboutCommand();
@@ -90,9 +94,13 @@ public class App : Application
void OnQuitClicked(object sender, EventArgs args)
{
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow is not MainWindow mainWindow ||
mainWindow.DataContext is not MainWindowViewModel mainWindowViewModel)
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime
{
MainWindow: MainWindow
{
DataContext: MainWindowViewModel mainWindowViewModel
}
})
return;
mainWindowViewModel.ExecuteExitCommand();
@@ -100,9 +108,13 @@ public class App : Application
void OnPreferencesClicked(object sender, EventArgs args)
{
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
desktop.MainWindow is not MainWindow mainWindow ||
mainWindow.DataContext is not MainWindowViewModel mainWindowViewModel)
if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime
{
MainWindow: MainWindow
{
DataContext: MainWindowViewModel mainWindowViewModel
}
})
return;
mainWindowViewModel.ExecuteSettingsCommand();