mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
Code Clean up: Use Pattern Matching (#5838)
Co-authored-by: Cody Robibero <cody@robibe.ro> Co-authored-by: Patrick Barron <18354464+barronpm@users.noreply.github.com>
This commit is contained in:
@@ -354,9 +354,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (result.Count == 0)
|
||||
{
|
||||
var folder = LibraryManager.FindByPath(path, true) as Folder;
|
||||
|
||||
if (folder != null)
|
||||
if (LibraryManager.FindByPath(path, true) is Folder folder)
|
||||
{
|
||||
result.Add(folder);
|
||||
}
|
||||
|
||||
@@ -217,8 +217,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
|
||||
private IEnumerable<BaseItem> FlattenItems(BaseItem item, List<Guid> expandedFolders)
|
||||
{
|
||||
var boxset = item as BoxSet;
|
||||
if (boxset != null)
|
||||
if (item is BoxSet boxset)
|
||||
{
|
||||
if (!expandedFolders.Contains(item.Id))
|
||||
{
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var parents = GetParents();
|
||||
foreach (var parent in parents)
|
||||
{
|
||||
var photoAlbum = parent as PhotoAlbum;
|
||||
if (photoAlbum != null)
|
||||
if (parent is PhotoAlbum photoAlbum)
|
||||
{
|
||||
return photoAlbum;
|
||||
}
|
||||
|
||||
@@ -316,20 +316,13 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var skipItem = false;
|
||||
|
||||
var episode = item as Episode;
|
||||
|
||||
if (episode != null
|
||||
bool skipItem = item is Episode episode
|
||||
&& refreshOptions.MetadataRefreshMode != MetadataRefreshMode.FullRefresh
|
||||
&& !refreshOptions.ReplaceAllMetadata
|
||||
&& episode.IsMissingEpisode
|
||||
&& episode.LocationType == LocationType.Virtual
|
||||
&& episode.PremiereDate.HasValue
|
||||
&& (DateTime.UtcNow - episode.PremiereDate.Value).TotalDays > 30)
|
||||
{
|
||||
skipItem = true;
|
||||
}
|
||||
&& (DateTime.UtcNow - episode.PremiereDate.Value).TotalDays > 30;
|
||||
|
||||
if (!skipItem)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
ContainingFolderPath = item.ContainingFolderPath;
|
||||
IsInMixedFolder = item.IsInMixedFolder;
|
||||
|
||||
var video = item as Video;
|
||||
if (video != null)
|
||||
if (item is Video video)
|
||||
{
|
||||
VideoType = video.VideoType;
|
||||
IsPlaceHolder = video.IsPlaceHolder;
|
||||
|
||||
Reference in New Issue
Block a user