Replace != null with is not null

This commit is contained in:
Bond_009
2022-12-05 15:01:13 +01:00
parent c7d50d640e
commit 52194f56b5
218 changed files with 928 additions and 928 deletions

View File

@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.IO
IEnumerable<BaseItem> itemsToRefresh = paths
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(GetAffectedBaseItem)
.Where(item => item != null)
.Where(item => item is not null)
.GroupBy(x => x!.Id) // Removed null values in the previous .Where()
.Select(x => x.First())!;
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.IO
path = System.IO.Path.GetDirectoryName(path) ?? string.Empty;
}
if (item != null)
if (item is not null)
{
// If the item has been deleted find the first valid parent that still exists
while (!Directory.Exists(item.Path) && !File.Exists(item.Path))
@@ -206,7 +206,7 @@ namespace Emby.Server.Implementations.IO
{
lock (_timerLock)
{
if (_timer != null)
if (_timer is not null)
{
_timer.Dispose();
_timer = null;

View File

@@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.IO
var options = _libraryManager.GetLibraryOptions(item);
if (options != null)
if (options is not null)
{
return options.EnableRealtimeMonitor;
}

View File

@@ -149,7 +149,7 @@ namespace Emby.Server.Implementations.IO
var extension = Path.GetExtension(shortcutPath);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
if (handler != null)
if (handler is not null)
{
handler.Create(shortcutPath, target);
}
@@ -621,14 +621,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Count == 1)
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Count == 1)
{
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions));
}
var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions);
if (extensions != null && extensions.Count > 0)
if (extensions is not null && extensions.Count > 0)
{
files = files.Where(i =>
{
@@ -678,14 +678,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Length == 1)
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Length == 1)
{
return Directory.EnumerateFiles(path, "*" + extensions[0], enumerationOptions);
}
var files = Directory.EnumerateFiles(path, "*", enumerationOptions);
if (extensions != null && extensions.Length > 0)
if (extensions is not null && extensions.Length > 0)
{
files = files.Where(i =>
{

View File

@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.IO
await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false);
if (onStarted != null)
if (onStarted is not null)
{
onStarted();
onStarted = null;