Jim Cartlidge 4 lat temu
rodzic
commit
c41ed13b3d

+ 16 - 2
Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs

@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Collections.Generic;
 using System.Xml;
@@ -10,8 +8,16 @@ using Microsoft.Extensions.Logging;
 
 namespace Emby.Dlna.MediaReceiverRegistrar
 {
+    /// <summary>
+    /// Defines the <see cref="ControlHandler" />.
+    /// </summary>
     public class ControlHandler : BaseControlHandler
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ControlHandler"/> class.
+        /// </summary>
+        /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
+        /// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
         public ControlHandler(IServerConfigurationManager config, ILogger logger)
             : base(config, logger)
         {
@@ -35,9 +41,17 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
         }
 
+        /// <summary>
+        /// Records that the handle is authorized in the xml stream.
+        /// </summary>
+        /// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
         private static void HandleIsAuthorized(XmlWriter xmlWriter)
             => xmlWriter.WriteElementString("Result", "1");
 
+        /// <summary>
+        /// Records that the handle is validated in the xml stream.
+        /// </summary>
+        /// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
         private static void HandleIsValidated(XmlWriter xmlWriter)
             => xmlWriter.WriteElementString("Result", "1");
     }

+ 10 - 3
Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarService.cs

@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
 using System.Net.Http;
 using System.Threading.Tasks;
 using Emby.Dlna.Service;
@@ -8,10 +6,19 @@ using Microsoft.Extensions.Logging;
 
 namespace Emby.Dlna.MediaReceiverRegistrar
 {
+    /// <summary>
+    /// Defines the <see cref="MediaReceiverRegistrarService" />.
+    /// </summary>
     public class MediaReceiverRegistrarService : BaseService, IMediaReceiverRegistrar
     {
         private readonly IServerConfigurationManager _config;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MediaReceiverRegistrarService"/> class.
+        /// </summary>
+        /// <param name="logger">The <see cref="ILogger{MediaReceiverRegistrarService}"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
+        /// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
+        /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
         public MediaReceiverRegistrarService(
             ILogger<MediaReceiverRegistrarService> logger,
             IHttpClientFactory httpClientFactory,
@@ -24,7 +31,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar
         /// <inheritdoc />
         public string GetServiceXml()
         {
-            return new MediaReceiverRegistrarXmlBuilder().GetXml();
+            return MediaReceiverRegistrarXmlBuilder.GetXml();
         }
 
         /// <inheritdoc />

+ 66 - 56
Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs

@@ -1,79 +1,89 @@
-#pragma warning disable CS1591
-
 using System.Collections.Generic;
 using Emby.Dlna.Common;
 using Emby.Dlna.Service;
+using MediaBrowser.Model.Dlna;
 
 namespace Emby.Dlna.MediaReceiverRegistrar
 {
-    public class MediaReceiverRegistrarXmlBuilder
+    /// <summary>
+    /// Defines the <see cref="MediaReceiverRegistrarXmlBuilder" />.
+    /// See https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drmnd/5d37515e-7a63-4709-8258-8fd4e0ed4482.
+    /// </summary>
+    public static class MediaReceiverRegistrarXmlBuilder
     {
-        public string GetXml()
+        /// <summary>
+        /// Retrieves an XML description of the X_MS_MediaReceiverRegistrar.
+        /// </summary>
+        /// <returns>An XML representation of this service.</returns>
+        public static string GetXml()
         {
-            return new ServiceXmlBuilder().GetXml(
-                new ServiceActionListBuilder().GetActions(),
-                GetStateVariables());
+            return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables());
         }
 
+        /// <summary>
+        /// The a list of all the state variables for this invocation.
+        /// </summary>
+        /// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
         private static IEnumerable<StateVariable> GetStateVariables()
         {
-            var list = new List<StateVariable>();
-
-            list.Add(new StateVariable
+            var list = new List<StateVariable>
             {
-                Name = "AuthorizationGrantedUpdateID",
-                DataType = "ui4",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "AuthorizationGrantedUpdateID",
+                    DataType = "ui4",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_DeviceID",
-                DataType = "string",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_DeviceID",
+                    DataType = "string",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "AuthorizationDeniedUpdateID",
-                DataType = "ui4",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "AuthorizationDeniedUpdateID",
+                    DataType = "ui4",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "ValidationSucceededUpdateID",
-                DataType = "ui4",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "ValidationSucceededUpdateID",
+                    DataType = "ui4",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_RegistrationRespMsg",
-                DataType = "bin.base64",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_RegistrationRespMsg",
+                    DataType = "bin.base64",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_RegistrationReqMsg",
-                DataType = "bin.base64",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_RegistrationReqMsg",
+                    DataType = "bin.base64",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "ValidationRevokedUpdateID",
-                DataType = "ui4",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "ValidationRevokedUpdateID",
+                    DataType = "ui4",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_Result",
-                DataType = "int",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_Result",
+                    DataType = "int",
+                    SendsEvents = false
+                }
+            };
 
             return list;
         }

+ 41 - 7
Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs

@@ -1,13 +1,19 @@
-#pragma warning disable CS1591
-
 using System.Collections.Generic;
 using Emby.Dlna.Common;
+using MediaBrowser.Model.Dlna;
 
 namespace Emby.Dlna.MediaReceiverRegistrar
 {
-    public class ServiceActionListBuilder
+    /// <summary>
+    /// Defines the <see cref="ServiceActionListBuilder" />.
+    /// </summary>
+    public static class ServiceActionListBuilder
     {
-        public IEnumerable<ServiceAction> GetActions()
+        /// <summary>
+        /// Returns a list of services that this instance provides.
+        /// </summary>
+        /// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
+        public static IEnumerable<ServiceAction> GetActions()
         {
             return new[]
             {
@@ -21,6 +27,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             };
         }
 
+        /// <summary>
+        /// Returns the action details for "IsValidated".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction GetIsValidated()
         {
             var action = new ServiceAction
@@ -43,6 +53,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
+        /// <summary>
+        /// Returns the action details for "IsAuthorized".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction GetIsAuthorized()
         {
             var action = new ServiceAction
@@ -65,6 +79,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
+        /// <summary>
+        /// Returns the action details for "RegisterDevice".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction GetRegisterDevice()
         {
             var action = new ServiceAction
@@ -87,6 +105,10 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
+        /// <summary>
+        /// Returns the action details for "GetValidationSucceededUpdateID".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction GetGetValidationSucceededUpdateID()
         {
             var action = new ServiceAction
@@ -103,7 +125,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
-        private ServiceAction GetGetAuthorizationDeniedUpdateID()
+        /// <summary>
+        /// Returns the action details for "GetGetAuthorizationDeniedUpdateID".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction GetGetAuthorizationDeniedUpdateID()
         {
             var action = new ServiceAction
             {
@@ -119,7 +145,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
-        private ServiceAction GetGetValidationRevokedUpdateID()
+        /// <summary>
+        /// Returns the action details for "GetValidationRevokedUpdateID".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction GetGetValidationRevokedUpdateID()
         {
             var action = new ServiceAction
             {
@@ -135,7 +165,11 @@ namespace Emby.Dlna.MediaReceiverRegistrar
             return action;
         }
 
-        private ServiceAction GetGetAuthorizationGrantedUpdateID()
+        /// <summary>
+        /// Returns the action details for "GetAuthorizationGrantedUpdateID".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction GetGetAuthorizationGrantedUpdateID()
         {
             var action = new ServiceAction
             {

+ 7 - 13
Emby.Dlna/Service/BaseControlHandler.cs

@@ -60,10 +60,8 @@ namespace Emby.Dlna.Service
                     Async = true
                 };
 
-                using (var reader = XmlReader.Create(streamReader, readerSettings))
-                {
-                    requestInfo = await ParseRequestAsync(reader).ConfigureAwait(false);
-                }
+                using var reader = XmlReader.Create(streamReader, readerSettings);
+                requestInfo = await ParseRequestAsync(reader).ConfigureAwait(false);
             }
 
             Logger.LogDebug("Received control request {0}", requestInfo.LocalName);
@@ -124,10 +122,8 @@ namespace Emby.Dlna.Service
                             {
                                 if (!reader.IsEmptyElement)
                                 {
-                                    using (var subReader = reader.ReadSubtree())
-                                    {
-                                        return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
-                                    }
+                                    using var subReader = reader.ReadSubtree();
+                                    return await ParseBodyTagAsync(subReader).ConfigureAwait(false);
                                 }
                                 else
                                 {
@@ -170,11 +166,9 @@ namespace Emby.Dlna.Service
 
                     if (!reader.IsEmptyElement)
                     {
-                        using (var subReader = reader.ReadSubtree())
-                        {
-                            await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
-                            return result;
-                        }
+                        using var subReader = reader.ReadSubtree();
+                        await ParseFirstBodyChildAsync(subReader, result.Headers).ConfigureAwait(false);
+                        return result;
                     }
                     else
                     {