aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2019-01-31 21:11:13 -0500
committerGitHub <noreply@github.com>2019-01-31 21:11:13 -0500
commitc713824bf960b1c0d33dde051da6115f329cbca8 (patch)
tree048d7dfbd47da525cbc5fd7551ea3e27fa643e5e /Emby.Dlna
parentea851317e76bca0ae4c02547bf7ae017a5a45282 (diff)
parent1ea219bf3f5c0708c3afa5fa2d897ca5212b5e04 (diff)
Merge pull request #734 from Bond-009/culture
Fix more analyzer warnings
Diffstat (limited to 'Emby.Dlna')
-rw-r--r--Emby.Dlna/Api/DlnaServerService.cs4
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs8
-rw-r--r--Emby.Dlna/DlnaManager.cs6
-rw-r--r--Emby.Dlna/Main/DlnaEntryPoint.cs2
-rw-r--r--Emby.Dlna/PlayTo/Device.cs68
-rw-r--r--Emby.Dlna/Server/DescriptionXmlBuilder.cs146
6 files changed, 124 insertions, 110 deletions
diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs
index 01c9fe50f..68bf80163 100644
--- a/Emby.Dlna/Api/DlnaServerService.cs
+++ b/Emby.Dlna/Api/DlnaServerService.cs
@@ -236,7 +236,9 @@ namespace Emby.Dlna.Api
public object Get(GetIcon request)
{
- var contentType = "image/" + Path.GetExtension(request.Filename).TrimStart('.').ToLower();
+ var contentType = "image/" + Path.GetExtension(request.Filename)
+ .TrimStart('.')
+ .ToLowerInvariant();
var cacheLength = TimeSpan.FromDays(365);
var cacheKey = Request.RawUrl.GetMD5();
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index d6f159d76..f6d923a1f 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -265,7 +265,7 @@ namespace Emby.Dlna.Didl
// <sec:CaptionInfo sec:type="srt">http://192.168.1.3:9999/video.srt</sec:CaptionInfo>
writer.WriteStartElement("sec", "CaptionInfoEx", null);
- writer.WriteAttributeString("sec", "type", null, info.Format.ToLower());
+ writer.WriteAttributeString("sec", "type", null, info.Format.ToLowerInvariant());
writer.WriteString(info.Url);
writer.WriteFullEndElement();
@@ -282,7 +282,7 @@ namespace Emby.Dlna.Didl
else
{
writer.WriteStartElement(string.Empty, "res", NS_DIDL);
- var protocolInfo = string.Format("http-get:*:text/{0}:*", info.Format.ToLower());
+ var protocolInfo = string.Format("http-get:*:text/{0}:*", info.Format.ToLowerInvariant());
writer.WriteAttributeString("protocolInfo", protocolInfo);
writer.WriteString(info.Url);
@@ -844,7 +844,7 @@ namespace Emby.Dlna.Didl
// var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase))
// ?? PersonType.Actor;
- // AddValue(writer, "upnp", type.ToLower(), actor.Name, NS_UPNP);
+ // AddValue(writer, "upnp", type.ToLowerInvariant(), actor.Name, NS_UPNP);
// index++;
@@ -1147,7 +1147,7 @@ namespace Emby.Dlna.Didl
if (stubType.HasValue)
{
- id = stubType.Value.ToString().ToLower() + "_" + id;
+ id = stubType.Value.ToString().ToLowerInvariant() + "_" + id;
}
return id;
diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs
index fd7b408fd..a43888270 100644
--- a/Emby.Dlna/DlnaManager.cs
+++ b/Emby.Dlna/DlnaManager.cs
@@ -300,7 +300,7 @@ namespace Emby.Dlna
profile = ReserializeProfile(tempProfile);
- profile.Id = path.ToLower().GetMD5().ToString("N");
+ profile.Id = path.ToLowerInvariant().GetMD5().ToString("N");
_profiles[path] = new Tuple<InternalProfileInfo, DeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile);
@@ -352,7 +352,7 @@ namespace Emby.Dlna
Info = new DeviceProfileInfo
{
- Id = file.FullName.ToLower().GetMD5().ToString("N"),
+ Id = file.FullName.ToLowerInvariant().GetMD5().ToString("N"),
Name = _fileSystem.GetFileNameWithoutExtension(file),
Type = type
}
@@ -506,7 +506,7 @@ namespace Emby.Dlna
? ImageFormat.Png
: ImageFormat.Jpg;
- var resource = GetType().Namespace + ".Images." + filename.ToLower();
+ var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
return new ImageStream
{
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs
index 1ab6014eb..ad90da49b 100644
--- a/Emby.Dlna/Main/DlnaEntryPoint.cs
+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs
@@ -263,7 +263,7 @@ namespace Emby.Dlna.Main
var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
- _logger.LogInformation("Registering publisher for {0} on {1}", fullService, address.ToString());
+ _logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);
var descriptorUri = "/dlna/" + udn + "/description.xml";
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs
index 68aa0a6a7..85a522d1c 100644
--- a/Emby.Dlna/PlayTo/Device.cs
+++ b/Emby.Dlna/PlayTo/Device.cs
@@ -902,54 +902,75 @@ namespace Emby.Dlna.PlayTo
var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault();
if (name != null && !string.IsNullOrWhiteSpace(name.Value))
+ {
friendlyNames.Add(name.Value);
+ }
var room = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault();
if (room != null && !string.IsNullOrWhiteSpace(room.Value))
+ {
friendlyNames.Add(room.Value);
+ }
- deviceProperties.Name = string.Join(" ", friendlyNames.ToArray());
+ deviceProperties.Name = string.Join(" ", friendlyNames);
var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
if (model != null)
+ {
deviceProperties.ModelName = model.Value;
+ }
var modelNumber = document.Descendants(uPnpNamespaces.ud.GetName("modelNumber")).FirstOrDefault();
if (modelNumber != null)
+ {
deviceProperties.ModelNumber = modelNumber.Value;
+ }
var uuid = document.Descendants(uPnpNamespaces.ud.GetName("UDN")).FirstOrDefault();
if (uuid != null)
+ {
deviceProperties.UUID = uuid.Value;
+ }
var manufacturer = document.Descendants(uPnpNamespaces.ud.GetName("manufacturer")).FirstOrDefault();
if (manufacturer != null)
+ {
deviceProperties.Manufacturer = manufacturer.Value;
+ }
var manufacturerUrl = document.Descendants(uPnpNamespaces.ud.GetName("manufacturerURL")).FirstOrDefault();
if (manufacturerUrl != null)
+ {
deviceProperties.ManufacturerUrl = manufacturerUrl.Value;
+ }
var presentationUrl = document.Descendants(uPnpNamespaces.ud.GetName("presentationURL")).FirstOrDefault();
if (presentationUrl != null)
+ {
deviceProperties.PresentationUrl = presentationUrl.Value;
+ }
var modelUrl = document.Descendants(uPnpNamespaces.ud.GetName("modelURL")).FirstOrDefault();
if (modelUrl != null)
+ {
deviceProperties.ModelUrl = modelUrl.Value;
+ }
var serialNumber = document.Descendants(uPnpNamespaces.ud.GetName("serialNumber")).FirstOrDefault();
if (serialNumber != null)
+ {
deviceProperties.SerialNumber = serialNumber.Value;
+ }
var modelDescription = document.Descendants(uPnpNamespaces.ud.GetName("modelDescription")).FirstOrDefault();
if (modelDescription != null)
+ {
deviceProperties.ModelDescription = modelDescription.Value;
+ }
deviceProperties.BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port);
var icon = document.Descendants(uPnpNamespaces.ud.GetName("icon")).FirstOrDefault();
-
if (icon != null)
{
deviceProperties.Icon = CreateIcon(icon);
@@ -958,12 +979,16 @@ namespace Emby.Dlna.PlayTo
foreach (var services in document.Descendants(uPnpNamespaces.ud.GetName("serviceList")))
{
if (services == null)
+ {
continue;
+ }
var servicesList = services.Descendants(uPnpNamespaces.ud.GetName("service"));
if (servicesList == null)
+ {
continue;
+ }
foreach (var element in servicesList)
{
@@ -1065,13 +1090,10 @@ namespace Emby.Dlna.PlayTo
private void OnPlaybackStart(uBaseObject mediaInfo)
{
- if (PlaybackStart != null)
+ PlaybackStart?.Invoke(this, new PlaybackStartEventArgs
{
- PlaybackStart.Invoke(this, new PlaybackStartEventArgs
- {
- MediaInfo = mediaInfo
- });
- }
+ MediaInfo = mediaInfo
+ });
}
private void OnPlaybackProgress(uBaseObject mediaInfo)
@@ -1082,36 +1104,28 @@ namespace Emby.Dlna.PlayTo
return;
}
- if (PlaybackProgress != null)
+ PlaybackProgress?.Invoke(this, new PlaybackProgressEventArgs
{
- PlaybackProgress.Invoke(this, new PlaybackProgressEventArgs
- {
- MediaInfo = mediaInfo
- });
- }
+ MediaInfo = mediaInfo
+ });
}
private void OnPlaybackStop(uBaseObject mediaInfo)
{
- if (PlaybackStopped != null)
+
+ PlaybackStopped?.Invoke(this, new PlaybackStoppedEventArgs
{
- PlaybackStopped.Invoke(this, new PlaybackStoppedEventArgs
- {
- MediaInfo = mediaInfo
- });
- }
+ MediaInfo = mediaInfo
+ });
}
private void OnMediaChanged(uBaseObject old, uBaseObject newMedia)
{
- if (MediaChanged != null)
+ MediaChanged?.Invoke(this, new MediaChangedEventArgs
{
- MediaChanged.Invoke(this, new MediaChangedEventArgs
- {
- OldMediaInfo = old,
- NewMediaInfo = newMedia
- });
- }
+ OldMediaInfo = old,
+ NewMediaInfo = newMedia
+ });
}
#region IDisposable
diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
index e0ecbee43..03d8f80ab 100644
--- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs
+++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs
@@ -107,19 +107,19 @@ namespace Emby.Dlna.Server
'&'
};
- private static readonly string[] s_escapeStringPairs = new string[]
-{
- "<",
- "&lt;",
- ">",
- "&gt;",
- "\"",
- "&quot;",
- "'",
- "&apos;",
- "&",
- "&amp;"
-};
+ private static readonly string[] s_escapeStringPairs = new[]
+ {
+ "<",
+ "&lt;",
+ ">",
+ "&gt;",
+ "\"",
+ "&quot;",
+ "'",
+ "&apos;",
+ "&",
+ "&amp;"
+ };
private static string GetEscapeSequence(char c)
{
@@ -133,7 +133,7 @@ namespace Emby.Dlna.Server
return result;
}
}
- return c.ToString();
+ return c.ToString(CultureInfo.InvariantCulture);
}
/// <summary>Replaces invalid XML characters in a string with their valid XML equivalent.</summary>
@@ -145,6 +145,7 @@ namespace Emby.Dlna.Server
{
return null;
}
+
StringBuilder stringBuilder = null;
int length = str.Length;
int num = 0;
@@ -230,9 +231,9 @@ namespace Emby.Dlna.Server
var serverName = new string(characters);
- var name = (_profile.FriendlyName ?? string.Empty).Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase);
+ var name = _profile.FriendlyName?.Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase);
- return name;
+ return name ?? string.Empty;
}
private void AppendIconList(StringBuilder builder)
@@ -295,65 +296,62 @@ namespace Emby.Dlna.Server
}
private IEnumerable<DeviceIcon> GetIcons()
- {
- var list = new List<DeviceIcon>();
-
- list.Add(new DeviceIcon
- {
- MimeType = "image/png",
- Depth = "24",
- Width = 240,
- Height = 240,
- Url = "icons/logo240.png"
- });
-
- list.Add(new DeviceIcon
- {
- MimeType = "image/jpeg",
- Depth = "24",
- Width = 240,
- Height = 240,
- Url = "icons/logo240.jpg"
- });
-
- list.Add(new DeviceIcon
- {
- MimeType = "image/png",
- Depth = "24",
- Width = 120,
- Height = 120,
- Url = "icons/logo120.png"
- });
-
- list.Add(new DeviceIcon
- {
- MimeType = "image/jpeg",
- Depth = "24",
- Width = 120,
- Height = 120,
- Url = "icons/logo120.jpg"
- });
-
- list.Add(new DeviceIcon
- {
- MimeType = "image/png",
- Depth = "24",
- Width = 48,
- Height = 48,
- Url = "icons/logo48.png"
- });
-
- list.Add(new DeviceIcon
+ => new[]
{
- MimeType = "image/jpeg",
- Depth = "24",
- Width = 48,
- Height = 48,
- Url = "icons/logo48.jpg"
- });
-
- return list;
- }
+ new DeviceIcon
+ {
+ MimeType = "image/png",
+ Depth = "24",
+ Width = 240,
+ Height = 240,
+ Url = "icons/logo240.png"
+ },
+
+ new DeviceIcon
+ {
+ MimeType = "image/jpeg",
+ Depth = "24",
+ Width = 240,
+ Height = 240,
+ Url = "icons/logo240.jpg"
+ },
+
+ new DeviceIcon
+ {
+ MimeType = "image/png",
+ Depth = "24",
+ Width = 120,
+ Height = 120,
+ Url = "icons/logo120.png"
+ },
+
+ new DeviceIcon
+ {
+ MimeType = "image/jpeg",
+ Depth = "24",
+ Width = 120,
+ Height = 120,
+ Url = "icons/logo120.jpg"
+ },
+
+ new DeviceIcon
+ {
+ MimeType = "image/png",
+ Depth = "24",
+ Width = 48,
+ Height = 48,
+ Url = "icons/logo48.png"
+ },
+
+ new DeviceIcon
+ {
+ MimeType = "image/jpeg",
+ Depth = "24",
+ Width = 48,
+ Height = 48,
+ Url = "icons/logo48.jpg"
+ }
+ };
private IEnumerable<DeviceService> GetServices()
{