aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Services/ServiceController.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2020-04-02 15:50:47 +0200
committerGitHub <noreply@github.com>2020-04-02 15:50:47 +0200
commit108172c00f822df994b3a27bbc5536ffdcbed09e (patch)
tree2fa9d20ad5ffb6bd47d47fe0231d6c787da46aca /Emby.Server.Implementations/Services/ServiceController.cs
parent89448ac055d584470d45892ad14e55c833e1a806 (diff)
parent2a521b0f68315a765ee1a970fabdd712739c4f31 (diff)
Merge pull request #2637 from mark-monteiro/do-not-instantiate-services-at-startup
Do not instantiate IService instances unecessarily at startup
Diffstat (limited to 'Emby.Server.Implementations/Services/ServiceController.cs')
-rw-r--r--Emby.Server.Implementations/Services/ServiceController.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
index d963f9043..e24a95dbb 100644
--- a/Emby.Server.Implementations/Services/ServiceController.cs
+++ b/Emby.Server.Implementations/Services/ServiceController.cs
@@ -3,14 +3,27 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Services
{
public delegate object ActionInvokerFn(object intance, object request);
+
public delegate void VoidActionInvokerFn(object intance, object request);
public class ServiceController
{
+ private readonly ILogger _logger;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ServiceController"/> class.
+ /// </summary>
+ /// <param name="logger">The <see cref="ServiceController"/> logger.</param>
+ public ServiceController(ILogger<ServiceController> logger)
+ {
+ _logger = logger;
+ }
+
public void Init(HttpListenerHost appHost, IEnumerable<Type> serviceTypes)
{
foreach (var serviceType in serviceTypes)
@@ -21,6 +34,13 @@ namespace Emby.Server.Implementations.Services
public void RegisterService(HttpListenerHost appHost, Type serviceType)
{
+ // Make sure the provided type implements IService
+ if (!typeof(IService).IsAssignableFrom(serviceType))
+ {
+ _logger.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType);
+ return;
+ }
+
var processedReqs = new HashSet<Type>();
var actions = ServiceExecGeneral.Reset(serviceType);