Convert type checks and null checks into pattern matching

This commit is contained in:
Patrick Barron
2020-04-05 12:07:43 -04:00
parent 29539174a3
commit 5966ee6d87
9 changed files with 24 additions and 54 deletions

View File

@@ -199,14 +199,12 @@ namespace MediaBrowser.Api.UserLibrary
item = _libraryManager.GetUserRootFolder();
}
Folder folder = item as Folder;
if (folder == null)
if (!(item is Folder folder))
{
folder = _libraryManager.GetUserRootFolder();
}
var hasCollectionType = folder as IHasCollectionType;
if (hasCollectionType != null
if (folder is IHasCollectionType hasCollectionType
&& string.Equals(hasCollectionType.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
{
request.Recursive = true;