diff options
Diffstat (limited to 'Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs')
| -rw-r--r-- | Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs b/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs index ae8175f4a..d8fb12742 100644 --- a/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs +++ b/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs @@ -1,44 +1,58 @@ using System; using System.Collections.Generic; +using System.Xml; using Emby.Dlna.Service; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Model.Xml; using Microsoft.Extensions.Logging; namespace Emby.Dlna.MediaReceiverRegistrar { + /// <summary> + /// Defines the <see cref="ControlHandler" />. + /// </summary> public class ControlHandler : BaseControlHandler { - protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, IDictionary<string, string> methodParams) + /// <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) { - if (string.Equals(methodName, "IsAuthorized", StringComparison.OrdinalIgnoreCase)) - return HandleIsAuthorized(); - if (string.Equals(methodName, "IsValidated", StringComparison.OrdinalIgnoreCase)) - return HandleIsValidated(); - - throw new ResourceNotFoundException("Unexpected control request name: " + methodName); } - private static IEnumerable<KeyValuePair<string, string>> HandleIsAuthorized() + /// <inheritdoc /> + protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter) { - return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) + if (string.Equals(methodName, "IsAuthorized", StringComparison.OrdinalIgnoreCase)) { - { "Result", "1" } - }; - } + HandleIsAuthorized(xmlWriter); + return; + } - private static IEnumerable<KeyValuePair<string, string>> HandleIsValidated() - { - return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) + if (string.Equals(methodName, "IsValidated", StringComparison.OrdinalIgnoreCase)) { - { "Result", "1" } - }; - } + HandleIsValidated(xmlWriter); + return; + } - public ControlHandler(IServerConfigurationManager config, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) - : base(config, logger, xmlReaderSettingsFactory) - { + 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"); } } |
