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

@@ -139,12 +139,12 @@ namespace Jellyfin.Server.Implementations.Devices
devices = devices.Where(device => device.UserId.Equals(query.UserId.Value));
}
if (query.DeviceId != null)
if (query.DeviceId is not null)
{
devices = devices.Where(device => device.DeviceId == query.DeviceId);
}
if (query.AccessToken != null)
if (query.AccessToken is not null)
{
devices = devices.Where(device => device.AccessToken == query.AccessToken);
}

View File

@@ -44,7 +44,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return;
}
if (eventArgs.Item != null && eventArgs.Item.IsThemeMedia)
if (eventArgs.Item is not null && eventArgs.Item.IsThemeMedia)
{
// Don't report theme song or local trailer playback
return;
@@ -78,7 +78,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
name = item.SeriesName + " - " + name;
}
if (item.Artists != null && item.Artists.Count > 0)
if (item.Artists is not null && item.Artists.Count > 0)
{
name = item.Artists[0] + " - " + name;
}

View File

@@ -46,7 +46,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return;
}
if (eventArgs.Item != null && eventArgs.Item.IsThemeMedia)
if (eventArgs.Item is not null && eventArgs.Item.IsThemeMedia)
{
// Don't report theme song or local trailer playback
return;
@@ -86,7 +86,7 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
name = item.SeriesName + " - " + name;
}
if (item.Artists != null && item.Artists.Count > 0)
if (item.Artists is not null && item.Artists.Count > 0)
{
name = item.Artists[0] + " - " + name;
}

View File

@@ -32,7 +32,7 @@ namespace Jellyfin.Server.Implementations.Security
public Task<AuthorizationInfo> GetAuthorizationInfo(HttpContext requestContext)
{
if (requestContext.Request.HttpContext.Items.TryGetValue("AuthorizationInfo", out var cached) && cached != null)
if (requestContext.Request.HttpContext.Items.TryGetValue("AuthorizationInfo", out var cached) && cached is not null)
{
return Task.FromResult((AuthorizationInfo)cached); // Cache should never contain null
}
@@ -72,7 +72,7 @@ namespace Jellyfin.Server.Implementations.Security
string? version = null;
string? token = null;
if (auth != null)
if (auth is not null)
{
auth.TryGetValue("DeviceId", out deviceId);
auth.TryGetValue("Device", out deviceName);
@@ -127,7 +127,7 @@ namespace Jellyfin.Server.Implementations.Security
{
var device = await dbContext.Devices.FirstOrDefaultAsync(d => d.AccessToken == token).ConfigureAwait(false);
if (device != null)
if (device is not null)
{
authInfo.IsAuthenticated = true;
var updateToken = false;
@@ -189,7 +189,7 @@ namespace Jellyfin.Server.Implementations.Security
else
{
var key = await dbContext.ApiKeys.FirstOrDefaultAsync(apiKey => apiKey.AccessToken == token).ConfigureAwait(false);
if (key != null)
if (key is not null)
{
authInfo.IsAuthenticated = true;
authInfo.Client = key.Name;

View File

@@ -286,7 +286,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/>
public async Task ChangeEasyPassword(User user, string newPassword, string? newPasswordSha1)
{
if (newPassword != null)
if (newPassword is not null)
{
newPasswordSha1 = _cryptoProvider.CreatePasswordHash(newPassword).ToString();
}
@@ -317,7 +317,7 @@ namespace Jellyfin.Server.Implementations.Users
EnableAutoLogin = user.EnableAutoLogin,
LastLoginDate = user.LastLoginDate,
LastActivityDate = user.LastActivityDate,
PrimaryImageTag = user.ProfileImage != null ? _imageProcessor.GetImageCacheTag(user) : null,
PrimaryImageTag = user.ProfileImage is not null ? _imageProcessor.GetImageCacheTag(user) : null,
Configuration = new UserConfiguration
{
SubtitleMode = user.SubtitleMode,
@@ -406,7 +406,7 @@ namespace Jellyfin.Server.Implementations.Users
string updatedUsername = authResult.Username;
if (success
&& authenticationProvider != null
&& authenticationProvider is not null
&& authenticationProvider is not DefaultAuthenticationProvider)
{
// Trust the username returned by the authentication provider
@@ -416,18 +416,18 @@ namespace Jellyfin.Server.Implementations.Users
// the authentication provider might have created it
user = Users.FirstOrDefault(i => string.Equals(username, i.Username, StringComparison.OrdinalIgnoreCase));
if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy && user != null)
if (authenticationProvider is IHasNewUserPolicy hasNewUserPolicy && user is not null)
{
await UpdatePolicyAsync(user.Id, hasNewUserPolicy.GetNewUserPolicy()).ConfigureAwait(false);
}
}
}
if (success && user != null && authenticationProvider != null)
if (success && user is not null && authenticationProvider is not null)
{
var providerId = authenticationProvider.GetType().FullName;
if (providerId != null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
if (providerId is not null && !string.Equals(providerId, user.AuthenticationProviderId, StringComparison.OrdinalIgnoreCase))
{
user.AuthenticationProviderId = providerId;
await UpdateUserAsync(user).ConfigureAwait(false);
@@ -501,7 +501,7 @@ namespace Jellyfin.Server.Implementations.Users
{
var user = string.IsNullOrWhiteSpace(enteredUsername) ? null : GetUserByName(enteredUsername);
if (user != null && isInNetwork)
if (user is not null && isInNetwork)
{
var passwordResetProvider = GetPasswordResetProvider(user);
var result = await passwordResetProvider