Use DI for ConnectionManagerService

This commit is contained in:
Patrick Barron 2023-10-11 11:08:19 -04:00
parent effc3d488c
commit e0b089a375
3 changed files with 8 additions and 11 deletions

View File

@ -3,6 +3,7 @@ using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Text;
using Emby.Dlna.ConnectionManager;
using Emby.Dlna.ContentDirectory;
using Emby.Dlna.Ssdp;
using MediaBrowser.Common.Net;
@ -50,5 +51,6 @@ public static class DlnaServiceCollectionExtensions
services.AddSingleton<IDlnaManager, DlnaManager>();
services.AddSingleton<IDeviceDiscovery, DeviceDiscovery>();
services.AddSingleton<IContentDirectory, ContentDirectoryService>();
services.AddSingleton<IConnectionManager, ConnectionManagerService>();
}
}

View File

@ -94,12 +94,6 @@ namespace Emby.Dlna.Main
_networkManager = networkManager;
_logger = loggerFactory.CreateLogger<DlnaEntryPoint>();
ConnectionManager = new ConnectionManager.ConnectionManagerService(
dlnaManager,
config,
loggerFactory.CreateLogger<ConnectionManager.ConnectionManagerService>(),
httpClientFactory);
MediaReceiverRegistrar = new MediaReceiverRegistrar.MediaReceiverRegistrarService(
loggerFactory.CreateLogger<MediaReceiverRegistrar.MediaReceiverRegistrarService>(),
httpClientFactory,
@ -122,8 +116,6 @@ namespace Emby.Dlna.Main
/// </summary>
public static bool Enabled { get; private set; }
public IConnectionManager ConnectionManager { get; private set; }
public IMediaReceiverRegistrar MediaReceiverRegistrar { get; private set; }
public async Task RunAsync()
@ -433,7 +425,6 @@ namespace Emby.Dlna.Main
_communicationsServer = null;
}
ConnectionManager = null;
MediaReceiverRegistrar = null;
Current = null;

View File

@ -34,11 +34,15 @@ public class DlnaServerController : BaseJellyfinApiController
/// </summary>
/// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
/// <param name="contentDirectory">Instance of the <see cref="IContentDirectory"/> interface.</param>
public DlnaServerController(IDlnaManager dlnaManager, IContentDirectory contentDirectory)
/// <param name="connectionManager">Instance of the <see cref="IConnectionManager"/> interface.</param>
public DlnaServerController(
IDlnaManager dlnaManager,
IContentDirectory contentDirectory,
IConnectionManager connectionManager)
{
_dlnaManager = dlnaManager;
_contentDirectory = contentDirectory;
_connectionManager = DlnaEntryPoint.Current.ConnectionManager;
_connectionManager = connectionManager;
_mediaReceiverRegistrar = DlnaEntryPoint.Current.MediaReceiverRegistrar;
}