aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2022-12-05 15:00:20 +0100
committerBond_009 <bond.009@outlook.com>2022-12-05 15:00:20 +0100
commitc7d50d640e614a3c13699e3041fbfcb258861c5a (patch)
tree85ce1a16c1af479160b805ec098463ae457b5228 /Emby.Dlna
parentb2def4c9ea6cf5e406bf5f865867d6cb5b54f640 (diff)
Replace == null with is null
Diffstat (limited to 'Emby.Dlna')
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs20
-rw-r--r--Emby.Dlna/DlnaManager.cs8
-rw-r--r--Emby.Dlna/Main/DlnaEntryPoint.cs2
-rw-r--r--Emby.Dlna/PlayTo/Device.cs94
-rw-r--r--Emby.Dlna/PlayTo/PlayToController.cs8
-rw-r--r--Emby.Dlna/PlayTo/PlayToManager.cs4
-rw-r--r--Emby.Dlna/Ssdp/DeviceDiscovery.cs6
7 files changed, 71 insertions, 71 deletions
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index 8e3a335c66..e2e3b2d8b6 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -191,7 +191,7 @@ namespace Emby.Dlna.Didl
private void AddVideoResource(XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo streamInfo = null)
{
- if (streamInfo == null)
+ if (streamInfo is null)
{
var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user);
@@ -263,7 +263,7 @@ namespace Emby.Dlna.Didl
.FirstOrDefault(i => string.Equals(info.Format, i.Format, StringComparison.OrdinalIgnoreCase)
&& i.Method == SubtitleDeliveryMethod.External);
- if (subtitleProfile == null)
+ if (subtitleProfile is null)
{
return false;
}
@@ -392,7 +392,7 @@ namespace Emby.Dlna.Didl
var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal));
- var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
+ var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
@@ -533,7 +533,7 @@ namespace Emby.Dlna.Didl
{
writer.WriteStartElement(string.Empty, "res", NsDidl);
- if (streamInfo == null)
+ if (streamInfo is null)
{
var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user);
@@ -598,7 +598,7 @@ namespace Emby.Dlna.Didl
var filename = url.Substring(0, url.IndexOf('?', StringComparison.Ordinal));
- var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
+ var mimeType = mediaProfile is null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
@@ -695,7 +695,7 @@ namespace Emby.Dlna.Didl
}
// Not a samsung device
- if (secAttribute == null)
+ if (secAttribute is null)
{
return;
}
@@ -909,7 +909,7 @@ namespace Emby.Dlna.Didl
AddValue(writer, "dc", "creator", artist, NsDc);
// If it doesn't support album artists (musicvideo), then tag as both
- if (hasAlbumArtists == null)
+ if (hasAlbumArtists is null)
{
AddAlbumArtist(writer, artist);
}
@@ -973,7 +973,7 @@ namespace Emby.Dlna.Didl
{
ImageDownloadInfo imageInfo = GetImageInfo(item);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return;
}
@@ -1036,7 +1036,7 @@ namespace Emby.Dlna.Didl
{
var imageInfo = GetImageInfo(item);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return;
}
@@ -1116,7 +1116,7 @@ namespace Emby.Dlna.Didl
private BaseItem GetFirstParentWithImageBelowUserRoot(BaseItem item)
{
- if (item == null)
+ if (item is null)
{
return null;
}
diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs
index 2ea2c130f2..31b999f64c 100644
--- a/Emby.Dlna/DlnaManager.cs
+++ b/Emby.Dlna/DlnaManager.cs
@@ -107,7 +107,7 @@ namespace Emby.Dlna
var profile = GetProfiles()
.FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification));
- if (profile == null)
+ if (profile is null)
{
_logger.LogInformation("No matching device profile found. The default will need to be used. \n{@Profile}", deviceInfo);
}
@@ -172,7 +172,7 @@ namespace Emby.Dlna
ArgumentNullException.ThrowIfNull(headers);
var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));
- if (profile == null)
+ if (profile is null)
{
_logger.LogDebug("No matching device profile found. {@Headers}", headers);
}
@@ -272,7 +272,7 @@ namespace Emby.Dlna
var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase));
- if (info == null)
+ if (info is null)
{
return null;
}
@@ -470,7 +470,7 @@ namespace Emby.Dlna
var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
var stream = _assembly.GetManifestResourceStream(resource);
- if (stream == null)
+ if (stream is null)
{
return null;
}
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs
index 15021c19d6..bcd7ece085 100644
--- a/Emby.Dlna/Main/DlnaEntryPoint.cs
+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs
@@ -199,7 +199,7 @@ namespace Emby.Dlna.Main
{
try
{
- if (_communicationsServer == null)
+ if (_communicationsServer is null)
{
var enableMultiSocketBinding = OperatingSystem.IsWindows() ||
OperatingSystem.IsLinux();
diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs
index 34981bd3f4..1c7730187b 100644
--- a/Emby.Dlna/PlayTo/Device.cs
+++ b/Emby.Dlna/PlayTo/Device.cs
@@ -220,14 +220,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetMute");
- if (command == null)
+ if (command is null)
{
return false;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return false;
}
@@ -260,14 +260,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -291,14 +291,14 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Seek");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -324,7 +324,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -337,7 +337,7 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -381,7 +381,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogDebug("{PropertyName} - SetNextAvTransport Uri: {Url} DlnaHeaders: {Header}", Properties.Name, url, header);
var command = avCommands.ServiceActions.FirstOrDefault(c => string.Equals(c.Name, "SetNextAVTransportURI", StringComparison.OrdinalIgnoreCase));
- if (command == null)
+ if (command is null)
{
return;
}
@@ -394,7 +394,7 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -418,13 +418,13 @@ namespace Emby.Dlna.PlayTo
private Task SetPlay(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Play");
- if (command == null)
+ if (command is null)
{
return Task.CompletedTask;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
@@ -440,7 +440,7 @@ namespace Emby.Dlna.PlayTo
public async Task SetPlay(CancellationToken cancellationToken)
{
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (avCommands == null)
+ if (avCommands is null)
{
return;
}
@@ -455,7 +455,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Stop");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -479,7 +479,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Pause");
- if (command == null)
+ if (command is null)
{
return;
}
@@ -513,7 +513,7 @@ namespace Emby.Dlna.PlayTo
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (avCommands == null)
+ if (avCommands is null)
{
return;
}
@@ -538,7 +538,7 @@ namespace Emby.Dlna.PlayTo
var currentObject = tuple.Track;
- if (tuple.Success && currentObject == null)
+ if (tuple.Success && currentObject is null)
{
currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false);
}
@@ -607,14 +607,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetVolume");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return;
}
@@ -626,7 +626,7 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return;
}
@@ -657,14 +657,14 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetMute");
- if (command == null)
+ if (command is null)
{
return;
}
var service = GetServiceRenderingControl();
- if (service == null)
+ if (service is null)
{
return;
}
@@ -676,7 +676,7 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return;
}
@@ -691,13 +691,13 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportState?> GetTransportInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetTransportInfo");
- if (command == null)
+ if (command is null)
{
return null;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
return null;
}
@@ -709,7 +709,7 @@ namespace Emby.Dlna.PlayTo
avCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return null;
}
@@ -731,19 +731,19 @@ namespace Emby.Dlna.PlayTo
private async Task<UBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo");
- if (command == null)
+ if (command is null)
{
return null;
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (rendererCommands == null)
+ if (rendererCommands is null)
{
return null;
}
@@ -755,14 +755,14 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return null;
}
var track = result.Document.Descendants("CurrentURIMetaData").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
return null;
}
@@ -778,7 +778,7 @@ namespace Emby.Dlna.PlayTo
track = result.Document.Descendants("CurrentURI").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
return null;
}
@@ -801,21 +801,21 @@ namespace Emby.Dlna.PlayTo
private async Task<(bool Success, UBaseObject Track)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo");
- if (command == null)
+ if (command is null)
{
return (false, null);
}
var service = GetAvTransportService();
- if (service == null)
+ if (service is null)
{
throw new InvalidOperationException("Unable to find service");
}
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
- if (rendererCommands == null)
+ if (rendererCommands is null)
{
return (false, null);
}
@@ -827,7 +827,7 @@ namespace Emby.Dlna.PlayTo
rendererCommands.BuildPost(command, service.ServiceType),
cancellationToken: cancellationToken).ConfigureAwait(false);
- if (result == null || result.Document == null)
+ if (result is null || result.Document is null)
{
return (false, null);
}
@@ -858,7 +858,7 @@ namespace Emby.Dlna.PlayTo
var track = result.Document.Descendants("TrackMetaData").FirstOrDefault();
- if (track == null)
+ if (track is null)
{
// If track is null, some vendors do this, use GetMediaInfo instead.
return (true, null);
@@ -882,7 +882,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogError(ex, "Uncaught exception while parsing xml");
}
- if (uPnpResponse == null)
+ if (uPnpResponse is null)
{
_logger.LogError("Failed to parse xml: \n {Xml}", trackString);
return (true, null);
@@ -985,7 +985,7 @@ namespace Emby.Dlna.PlayTo
}
var avService = GetAvTransportService();
- if (avService == null)
+ if (avService is null)
{
return null;
}
@@ -995,7 +995,7 @@ namespace Emby.Dlna.PlayTo
var httpClient = new DlnaHttpClient(_logger, _httpClientFactory);
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1017,7 +1017,7 @@ namespace Emby.Dlna.PlayTo
}
var avService = GetServiceRenderingControl();
- if (avService == null)
+ if (avService is null)
{
throw new ArgumentException("Device AvService is null");
}
@@ -1027,7 +1027,7 @@ namespace Emby.Dlna.PlayTo
var httpClient = new DlnaHttpClient(_logger, _httpClientFactory);
_logger.LogDebug("Dlna Device.GetRenderingProtocolAsync");
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1062,7 +1062,7 @@ namespace Emby.Dlna.PlayTo
var ssdpHttpClient = new DlnaHttpClient(logger, httpClientFactory);
var document = await ssdpHttpClient.GetDataAsync(url.ToString(), cancellationToken).ConfigureAwait(false);
- if (document == null)
+ if (document is null)
{
return null;
}
@@ -1149,13 +1149,13 @@ namespace Emby.Dlna.PlayTo
foreach (var services in document.Descendants(UPnpNamespaces.Ud.GetName("serviceList")))
{
- if (services == null)
+ if (services is null)
{
continue;
}
var servicesList = services.Descendants(UPnpNamespaces.Ud.GetName("service"));
- if (servicesList == null)
+ if (servicesList is null)
{
continue;
}
@@ -1212,14 +1212,14 @@ namespace Emby.Dlna.PlayTo
var previousMediaInfo = CurrentMediaInfo;
CurrentMediaInfo = mediaInfo;
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
if (previousMediaInfo != null)
{
OnPlaybackStop(previousMediaInfo);
}
}
- else if (previousMediaInfo == null)
+ else if (previousMediaInfo is null)
{
if (state != TransportState.STOPPED)
{
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index 65367e24f2..fca5fc2a0d 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo
}
streamInfo = StreamParams.ParseFromUrl(e.NewMediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (streamInfo.Item == null)
+ if (streamInfo.Item is null)
{
return;
}
@@ -199,7 +199,7 @@ namespace Emby.Dlna.PlayTo
{
var streamInfo = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager);
- if (streamInfo.Item == null)
+ if (streamInfo.Item is null)
{
return;
}
@@ -210,7 +210,7 @@ namespace Emby.Dlna.PlayTo
var mediaSource = await streamInfo.GetMediaSource(CancellationToken.None).ConfigureAwait(false);
- var duration = mediaSource == null
+ var duration = mediaSource is null
? _device.Duration?.Ticks
: mediaSource.RunTimeTicks;
@@ -865,7 +865,7 @@ namespace Emby.Dlna.PlayTo
throw new ObjectDisposedException(GetType().Name);
}
- if (_device == null)
+ if (_device is null)
{
return Task.CompletedTask;
}
diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs
index 294bda5b6a..f4a9a90af4 100644
--- a/Emby.Dlna/PlayTo/PlayToManager.cs
+++ b/Emby.Dlna/PlayTo/PlayToManager.cs
@@ -176,10 +176,10 @@ namespace Emby.Dlna.PlayTo
var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
- if (controller == null)
+ if (controller is null)
{
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClientFactory, _logger, cancellationToken).ConfigureAwait(false);
- if (device == null)
+ if (device is null)
{
_logger.LogError("Ignoring device as xml response is invalid.");
return;
diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
index 391dda1479..bb58a5d1b6 100644
--- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs
+++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
@@ -71,7 +71,7 @@ namespace Emby.Dlna.Ssdp
{
lock (_syncLock)
{
- if (_listenerCount > 0 && _deviceLocator == null && _commsServer != null)
+ if (_listenerCount > 0 && _deviceLocator is null && _commsServer != null)
{
_deviceLocator = new SsdpDeviceLocator(_commsServer);
@@ -97,7 +97,7 @@ namespace Emby.Dlna.Ssdp
{
var originalHeaders = e.DiscoveredDevice.ResponseHeaders;
- var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
+ var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
@@ -116,7 +116,7 @@ namespace Emby.Dlna.Ssdp
{
var originalHeaders = e.DiscoveredDevice.ResponseHeaders;
- var headerDict = originalHeaders == null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
+ var headerDict = originalHeaders is null ? new Dictionary<string, KeyValuePair<string, IEnumerable<string>>>() : originalHeaders.ToDictionary(i => i.Key, StringComparer.OrdinalIgnoreCase);
var headers = headerDict.ToDictionary(i => i.Key, i => i.Value.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);