diff options
| author | Bond_009 <bond.009@outlook.com> | 2022-12-05 15:01:13 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2022-12-05 15:01:13 +0100 |
| commit | 52194f56b5f07e3ae01e2fb6d121452e37d1e93f (patch) | |
| tree | fd638972f72ec49734ad07f831a3aae3b2501a1d /Emby.Server.Implementations/Library | |
| parent | c7d50d640e614a3c13699e3041fbfcb258861c5a (diff) | |
Replace != null with is not null
Diffstat (limited to 'Emby.Server.Implementations/Library')
14 files changed, 98 insertions, 98 deletions
diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index e558fbe27..665d70a41 100644 --- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Library if (fileInfo.IsDirectory) { - if (parent != null) + if (parent is not null) { // Ignore extras folders but allow it at the collection level if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename) @@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Library } else { - if (parent != null) + if (parent is not null) { // Don't resolve these into audio files if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringComparison.Ordinal) diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index e8f6d2d23..9ee8a630d 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -465,9 +465,9 @@ namespace Emby.Server.Implementations.Library private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers) { var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r)) - .FirstOrDefault(i => i != null); + .FirstOrDefault(i => i is not null); - if (item != null) + if (item is not null) { ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this); } @@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.Library var fullPath = fileInfo.FullName; - if (string.IsNullOrEmpty(collectionType) && parent != null) + if (string.IsNullOrEmpty(collectionType) && parent is not null) { collectionType = GetContentTypeOverride(fullPath, true); } @@ -572,7 +572,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - if (parent != null && parent.IsPhysicalRoot) + if (parent is not null && parent.IsPhysicalRoot) { _logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf); @@ -654,7 +654,7 @@ namespace Emby.Server.Implementations.Library { var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList(); - if (parent != null) + if (parent is not null) { var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray(); @@ -697,7 +697,7 @@ namespace Emby.Server.Implementations.Library _logger.LogError(ex, "Error resolving path {Path}", file.FullName); } - if (result != null) + if (result is not null) { yield return result; } @@ -750,7 +750,7 @@ namespace Emby.Server.Implementations.Library var dbItem = GetItemById(folder.Id) as BasePluginFolder; - if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase)) + if (dbItem is not null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase)) { folder = dbItem; } @@ -952,7 +952,7 @@ namespace Emby.Server.Implementations.Library .Cast<T>() .FirstOrDefault(); - if (existing != null) + if (existing is not null) { return existing; } @@ -1181,7 +1181,7 @@ namespace Emby.Server.Implementations.Library return null; } }) - .Where(i => i != null) + .Where(i => i is not null) .OrderBy(i => i) .ToArray(), @@ -1190,17 +1190,17 @@ namespace Emby.Server.Implementations.Library var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); - if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary)) + if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary)) { info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture); } - if (libraryFolder != null) + if (libraryFolder is not null) { info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture); info.LibraryOptions = GetLibraryOptions(libraryFolder); - if (refreshQueue != null) + if (refreshQueue is not null) { info.RefreshProgress = libraryFolder.GetRefreshProgress(); @@ -1245,7 +1245,7 @@ namespace Emby.Server.Implementations.Library item = RetrieveItem(id); - if (item != null) + if (item is not null) { RegisterItem(item); } @@ -1258,13 +1258,13 @@ namespace Emby.Server.Implementations.Library if (query.Recursive && !query.ParentId.Equals(default)) { var parent = GetItemById(query.ParentId); - if (parent != null) + if (parent is not null) { SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); } } - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User, allowExternalContent); } @@ -1282,13 +1282,13 @@ namespace Emby.Server.Implementations.Library if (query.Recursive && !query.ParentId.Equals(default)) { var parent = GetItemById(query.ParentId); - if (parent != null) + if (parent is not null) { SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); } } - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1302,7 +1302,7 @@ namespace Emby.Server.Implementations.Library if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1313,7 +1313,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<BaseItem> QueryItems(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1331,7 +1331,7 @@ namespace Emby.Server.Implementations.Library public List<Guid> GetItemIds(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1341,7 +1341,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1352,7 +1352,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1363,7 +1363,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1374,7 +1374,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1385,7 +1385,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1426,7 +1426,7 @@ namespace Emby.Server.Implementations.Library public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query) { - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1440,13 +1440,13 @@ namespace Emby.Server.Implementations.Library if (query.Recursive && !query.ParentId.Equals(default)) { var parent = GetItemById(query.ParentId); - if (parent != null) + if (parent is not null) { SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); } } - if (query.User != null) + if (query.User is not null) { AddUserToQuery(query, query.User); } @@ -1524,7 +1524,7 @@ namespace Emby.Server.Implementations.Library if (!view.DisplayParentId.Equals(default)) { var displayParent = GetItemById(view.DisplayParentId); - if (displayParent != null) + if (displayParent is not null) { return GetTopParentIdsForQuery(displayParent, user); } @@ -1535,7 +1535,7 @@ namespace Emby.Server.Implementations.Library if (!view.ParentId.Equals(default)) { var displayParent = GetItemById(view.ParentId); - if (displayParent != null) + if (displayParent is not null) { return GetTopParentIdsForQuery(displayParent, user); } @@ -1544,7 +1544,7 @@ namespace Emby.Server.Implementations.Library } // Handle grouping - if (user != null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType) + if (user is not null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType) && user.GetPreference(PreferenceKind.GroupedFolders).Length > 0) { return GetUserRootFolder() @@ -1564,7 +1564,7 @@ namespace Emby.Server.Implementations.Library } var topParent = item.GetTopParent(); - if (topParent != null) + if (topParent is not null) { return new[] { topParent.Id }; } @@ -1589,7 +1589,7 @@ namespace Emby.Server.Implementations.Library return items .SelectMany(i => i.ToArray()) .Select(ResolveIntro) - .Where(i => i != null); + .Where(i => i is not null); } /// <summary> @@ -1648,7 +1648,7 @@ namespace Emby.Server.Implementations.Library // Pull the saved db item that will include metadata var dbItem = GetItemById(video.Id) as Video; - if (dbItem != null) + if (dbItem is not null) { video = dbItem; } @@ -1685,7 +1685,7 @@ namespace Emby.Server.Implementations.Library IOrderedEnumerable<BaseItem> orderedItems = null; - foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c != null)) + foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c is not null)) { if (isFirst) { @@ -1781,7 +1781,7 @@ namespace Emby.Server.Implementations.Library RegisterItem(item); } - if (ItemAdded != null) + if (ItemAdded is not null) { foreach (var item in items) { @@ -1811,7 +1811,7 @@ namespace Emby.Server.Implementations.Library private bool ImageNeedsRefresh(ItemImageInfo image) { - if (image.Path != null && image.IsLocalFile) + if (image.Path is not null && image.IsLocalFile) { if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash)) { @@ -1829,7 +1829,7 @@ namespace Emby.Server.Implementations.Library } } - return image.Path != null && !image.IsLocalFile; + return image.Path is not null && !image.IsLocalFile; } /// <inheritdoc /> @@ -1838,7 +1838,7 @@ namespace Emby.Server.Implementations.Library ArgumentNullException.ThrowIfNull(item); var outdated = forceUpdate - ? item.ImageInfos.Where(i => i.Path != null).ToArray() + ? item.ImageInfos.Where(i => i.Path is not null).ToArray() : item.ImageInfos.Where(ImageNeedsRefresh).ToArray(); // Skip image processing if current or live tv source if (outdated.Length == 0 || item.SourceType != SourceType.Library) @@ -1923,7 +1923,7 @@ namespace Emby.Server.Implementations.Library _itemRepository.SaveItems(items, cancellationToken); - if (ItemUpdated != null) + if (ItemUpdated is not null) { foreach (var item in items) { @@ -1975,7 +1975,7 @@ namespace Emby.Server.Implementations.Library /// <param name="parent">The parent item.</param> public void ReportItemRemoved(BaseItem item, BaseItem parent) { - if (ItemRemoved != null) + if (ItemRemoved is not null) { try { @@ -2006,7 +2006,7 @@ namespace Emby.Server.Implementations.Library public List<Folder> GetCollectionFolders(BaseItem item) { - while (item != null) + while (item is not null) { var parent = item.GetParent(); @@ -2028,7 +2028,7 @@ namespace Emby.Server.Implementations.Library public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren) { - while (item != null) + while (item is not null) { var parent = item.GetParent(); @@ -2251,7 +2251,7 @@ namespace Emby.Server.Implementations.Library if (!refresh && !item.DisplayParentId.Equals(default)) { var displayParent = GetItemById(item.DisplayParentId); - refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; + refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed; } if (refresh) @@ -2315,7 +2315,7 @@ namespace Emby.Server.Implementations.Library if (!refresh && !item.DisplayParentId.Equals(default)) { var displayParent = GetItemById(item.DisplayParentId); - refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; + refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed; } if (refresh) @@ -2394,7 +2394,7 @@ namespace Emby.Server.Implementations.Library if (!refresh && !item.DisplayParentId.Equals(default)) { var displayParent = GetItemById(item.DisplayParentId); - refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; + refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed; } if (refresh) @@ -2441,7 +2441,7 @@ namespace Emby.Server.Implementations.Library public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh) { var series = episode.Series; - bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase); + bool? isAbsoluteNaming = series is not null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase); if (!isAbsoluteNaming.Value) { // In other words, no filter applied @@ -2462,7 +2462,7 @@ namespace Emby.Server.Implementations.Library if (episodeInfo is null && parent.GetType() == typeof(Folder)) { episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming); - if (episodeInfo != null) + if (episodeInfo is not null) { // add the container episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.'); @@ -2582,7 +2582,7 @@ namespace Emby.Server.Implementations.Library { var season = episode.Season; - if (season != null) + if (season is not null) { episode.ParentIndexNumber = season.IndexNumber; } @@ -2640,7 +2640,7 @@ namespace Emby.Server.Implementations.Library } var extra = GetExtra(file, extraType.Value); - if (extra != null) + if (extra is not null) { yield return extra; } @@ -2649,7 +2649,7 @@ namespace Emby.Server.Implementations.Library else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType)) { var extra = GetExtra(current, extraType.Value); - if (extra != null) + if (extra is not null) { yield return extra; } @@ -2666,7 +2666,7 @@ namespace Emby.Server.Implementations.Library // Try to retrieve it from the db. If we don't find it, use the resolved version var itemById = GetItemById(extra.Id); - if (itemById != null) + if (itemById is not null) { extra = itemById; } @@ -2681,10 +2681,10 @@ namespace Emby.Server.Implementations.Library public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem) { string newPath; - if (ownerItem != null) + if (ownerItem is not null) { var libraryOptions = GetLibraryOptions(ownerItem); - if (libraryOptions != null) + if (libraryOptions is not null) { foreach (var pathInfo in libraryOptions.PathInfos) { @@ -2753,7 +2753,7 @@ namespace Emby.Server.Implementations.Library return null; } }) - .Where(i => i != null) + .Where(i => i is not null) .Where(i => query.User is null ? true : i.IsVisible(query.User)) @@ -2838,10 +2838,10 @@ namespace Emby.Server.Implementations.Library } var mediaPathInfos = options.PathInfos; - if (mediaPathInfos != null) + if (mediaPathInfos is not null) { var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path)); - if (invalidpath != null) + if (invalidpath is not null) { throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + "."); } @@ -2853,7 +2853,7 @@ namespace Emby.Server.Implementations.Library { Directory.CreateDirectory(virtualFolderPath); - if (collectionType != null) + if (collectionType is not null) { var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection"); @@ -2862,7 +2862,7 @@ namespace Emby.Server.Implementations.Library CollectionFolder.SaveLibraryOptions(virtualFolderPath, options); - if (mediaPathInfos != null) + if (mediaPathInfos is not null) { foreach (var path in mediaPathInfos) { diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs index 101033551..936a08da8 100644 --- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs @@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Library }, cancellationToken).ConfigureAwait(false); - if (cacheFilePath != null) + if (cacheFilePath is not null) { Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); await using FileStream createStream = AsyncFile.OpenWrite(cacheFilePath); @@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library } var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); - if (videoStream != null) + if (videoStream is not null) { if (!videoStream.BitRate.HasValue) { diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index e2474f508..7fff6ab7b 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.Library source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol); } - if (user != null) + if (user is not null) { SetDefaultAudioAndSubtitleStreamIndexes(item, source, user); @@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Library if (protocol == MediaProtocol.Http) { - if (path != null) + if (path is not null) { if (path.Contains(".m3u", StringComparison.OrdinalIgnoreCase)) { @@ -328,7 +328,7 @@ namespace Emby.Server.Implementations.Library var sources = hasMediaSources.GetMediaSources(enablePathSubstitution); - if (user != null) + if (user is not null) { foreach (var source in sources) { @@ -357,7 +357,7 @@ namespace Emby.Server.Implementations.Library } var culture = _localizationManager.FindLanguageInfo(language); - if (culture != null) + if (culture is not null) { return culture.ThreeLetterISOLanguageNames; } @@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.Library { var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - if (audio != null) + if (audio is not null) { source.DefaultAudioStreamIndex = audio.Index; } @@ -553,7 +553,7 @@ namespace Emby.Server.Implementations.Library } var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); - if (videoStream != null) + if (videoStream is not null) { if (!videoStream.BitRate.HasValue) { @@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.Library }, cancellationToken).ConfigureAwait(false); - if (cacheFilePath != null) + if (cacheFilePath is not null) { Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); await using FileStream createStream = File.Create(cacheFilePath); @@ -723,7 +723,7 @@ namespace Emby.Server.Implementations.Library } var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); - if (videoStream != null) + if (videoStream is not null) { if (!videoStream.BitRate.HasValue) { diff --git a/Emby.Server.Implementations/Library/MediaStreamSelector.cs b/Emby.Server.Implementations/Library/MediaStreamSelector.cs index 609b95772..74c53b2da 100644 --- a/Emby.Server.Implementations/Library/MediaStreamSelector.cs +++ b/Emby.Server.Implementations/Library/MediaStreamSelector.cs @@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Library { var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault); - if (defaultStream != null) + if (defaultStream is not null) { return defaultStream.Index; } diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs index 590d37b92..dedb56d67 100644 --- a/Emby.Server.Implementations/Library/ResolverHelper.cs +++ b/Emby.Server.Implementations/Library/ResolverHelper.cs @@ -31,7 +31,7 @@ namespace Emby.Server.Implementations.Library } // If the resolver didn't specify this - if (parent != null) + if (parent is not null) { item.SetParent(parent); } @@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Library } // If the resolver didn't specify this - if (args.Parent != null) + if (args.Parent is not null) { item.SetParent(args.Parent); } @@ -113,7 +113,7 @@ namespace Emby.Server.Implementations.Library { var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null; - if (childData != null) + if (childData is not null) { SetDateCreated(item, childData); } @@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library if (config.UseFileCreationTimeForDateAdded) { // directoryService.getFile may return null - if (info != null) + if (info is not null) { var dateCreated = info.CreationTimeUtc; diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index bc1f5d08a..06621700a 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio { var result = ResolveMultipleInternal(parent, files, collectionType); - if (result != null) + if (result is not null) { foreach (var item in result.Items) { @@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio item = new AudioBook(); } - if (item != null) + if (item is not null) { item.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase); @@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio Items = items }; - var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent); + var isInMixedFolder = resolverResult.Count > 1 || (parent is not null && parent.IsTopParent); foreach (var resolvedItem in resolverResult) { diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs index 6fc200e3b..042422c6f 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books var extension = Path.GetExtension(args.Path); - if (extension != null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase)) + if (extension is not null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase)) { // It's a book return new Book diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 6b18ad237..5f1a3ec6d 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies { var result = ResolveMultipleInternal(parent, files, collectionType); - if (result != null) + if (result is not null) { foreach (var item in result.Items) { @@ -168,12 +168,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies } // Ignore extras - if (item?.ExtraType != null) + if (item?.ExtraType is not null) { return null; } - if (item != null) + if (item is not null) { item.IsInMixedFolder = true; } @@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies var videoInfos = files .Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName)) - .Where(f => f != null) + .Where(f => f is not null) .ToList(); var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName); @@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies { var firstVideo = video.Files[0]; var path = firstVideo.Path; - if (video.ExtraType != null) + if (video.ExtraType is not null) { result.ExtraFiles.Add(files.Find(f => string.Equals(f.FullName, path, StringComparison.OrdinalIgnoreCase))); continue; @@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies private bool IsInvalid(Folder parent, ReadOnlySpan<char> collectionType) { - if (parent != null) + if (parent is not null) { if (parent.IsRoot) { diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs index 2e2b79341..0fcc5070b 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs @@ -46,27 +46,27 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV // If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something // Also handle flat tv folders - if (season != null || + if (season is not null || string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || args.HasParent<Series>()) { var episode = ResolveVideo<Episode>(args, false); // Ignore extras - if (episode is null || episode.ExtraType != null) + if (episode is null || episode.ExtraType is not null) { return null; } var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault(); - if (series != null) + if (series is not null) { episode.SeriesId = series.Id; episode.SeriesName = series.Name; } - if (season != null) + if (season is not null) { episode.SeasonId = season.Id; episode.SeasonName = season.Name; diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs index ea4851458..62a524d2e 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs @@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV var episodeInfo = resolver.Resolve(testPath, true); - if (episodeInfo?.EpisodeNumber != null && episodeInfo.SeasonNumber.HasValue) + if (episodeInfo?.EpisodeNumber is not null && episodeInfo.SeasonNumber.HasValue) { _logger.LogDebug( "Found folder underneath series with episode number: {0}. Season {1}. Episode {2}", diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index f5ac3c665..8f69175d0 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV { if (args.ContainsFileSystemEntryByName("tvshow.nfo")) { - if (args.Parent != null && args.Parent.IsRoot) + if (args.Parent is not null && args.Parent.IsRoot) { // For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo return null; @@ -89,7 +89,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV }; } - if (args.Parent != null && args.Parent.IsRoot) + if (args.Parent is not null && args.Parent.IsRoot) { return null; } @@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions); var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false); - if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue) + if (episodeInfo is not null && episodeInfo.EpisodeNumber.HasValue) { return true; } diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index aecab7d9c..a0a90b129 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library { var userData = _repository.GetUserData(internalUserId, keys); - if (userData != null) + if (userData is not null) { return userData; } diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index c294a63db..1137625f4 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Library continue; } - if (collectionFolder != null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id)) + if (collectionFolder is not null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id)) { groupedFolders.Add(collectionFolder); continue; @@ -214,9 +214,9 @@ namespace Emby.Server.Implementations.Library } else { - var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id.Equals(container.Id)); + var current = list.FirstOrDefault(i => i.Item1 is not null && i.Item1.Id.Equals(container.Id)); - if (current != null) + if (current is not null) { current.Item2.Add(item); } |
