aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Channels/ChannelManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelManager.cs')
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs33
1 files changed, 15 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index 6837cce5c..85ccbc028 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.Channels
public Task DeleteItem(BaseItem item)
{
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
- if (internalChannel == null)
+ if (internalChannel is null)
{
throw new ArgumentException(nameof(item.ChannelId));
}
@@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.Channels
.ToList();
}
- if (user != null)
+ if (user is not null)
{
channels = channels.Where(i =>
{
@@ -253,7 +253,7 @@ namespace Emby.Server.Implementations.Channels
if (query.StartIndex.HasValue || query.Limit.HasValue)
{
int startIndex = query.StartIndex ?? 0;
- int count = query.Limit == null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
+ int count = query.Limit is null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
all = all.GetRange(startIndex, count);
}
@@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels
{
var path = Path.Combine(item.GetInternalMetadataPath(), "channelmediasourceinfos.json");
- if (mediaSources == null || mediaSources.Count == 0)
+ if (mediaSources is null || mediaSources.Count == 0)
{
try
{
@@ -447,7 +447,7 @@ namespace Emby.Server.Implementations.Channels
var item = _libraryManager.GetItemById(id) as Channel;
- if (item == null)
+ if (item is null)
{
item = new Channel
{
@@ -601,10 +601,7 @@ namespace Emby.Server.Implementations.Channels
private Guid GetInternalChannelId(string name)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel));
}
@@ -739,7 +736,7 @@ namespace Emby.Server.Implementations.Channels
query.GroupByPresentationUniqueKey = false;
// null if came from cache
- if (itemsResult != null)
+ if (itemsResult is not null)
{
var items = itemsResult.Items;
var itemsLen = items.Count;
@@ -761,7 +758,7 @@ namespace Emby.Server.Implementations.Channels
foreach (var deadId in deadIds)
{
var deadItem = _libraryManager.GetItemById(deadId);
- if (deadItem != null)
+ if (deadItem is not null)
{
_libraryManager.DeleteItem(
deadItem,
@@ -813,7 +810,7 @@ namespace Emby.Server.Implementations.Channels
{
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult != null)
+ if (cachedResult is not null)
{
return null;
}
@@ -836,7 +833,7 @@ namespace Emby.Server.Implementations.Channels
{
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (cachedResult != null)
+ if (cachedResult is not null)
{
return null;
}
@@ -861,7 +858,7 @@ namespace Emby.Server.Implementations.Channels
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
- if (result == null)
+ if (result is null)
{
throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
}
@@ -955,7 +952,7 @@ namespace Emby.Server.Implementations.Channels
_logger.LogError(ex, "Error retrieving channel item from database");
}
- if (item == null)
+ if (item is null)
{
item = new T();
isNew = true;
@@ -1156,7 +1153,7 @@ namespace Emby.Server.Implementations.Channels
{
_libraryManager.CreateItem(item, parentFolder);
- if (info.People != null && info.People.Count > 0)
+ if (info.People is not null && info.People.Count > 0)
{
_libraryManager.UpdatePeople(item, info.People);
}
@@ -1193,7 +1190,7 @@ namespace Emby.Server.Implementations.Channels
var result = GetAllChannels()
.FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase));
- if (result == null)
+ if (result is null)
{
throw new ResourceNotFoundException("No channel provider found for channel " + channel.Name);
}
@@ -1206,7 +1203,7 @@ namespace Emby.Server.Implementations.Channels
var result = GetAllChannels()
.FirstOrDefault(i => internalChannelId.Equals(GetInternalChannelId(i.Name)));
- if (result == null)
+ if (result is null)
{
throw new ResourceNotFoundException("No channel provider found for channel id " + internalChannelId);
}