mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
removed base kernel and ikernel
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseManager
|
||||
/// </summary>
|
||||
/// <typeparam name="TKernelType">The type of the T kernel type.</typeparam>
|
||||
public abstract class BaseManager<TKernelType> : IDisposable
|
||||
where TKernelType : class, IKernel
|
||||
{
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
/// </summary>
|
||||
protected readonly TKernelType Kernel;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <exception cref="System.ArgumentNullException">kernel</exception>
|
||||
protected BaseManager(TKernelType kernel)
|
||||
{
|
||||
if (kernel == null)
|
||||
{
|
||||
throw new ArgumentNullException("kernel");
|
||||
}
|
||||
|
||||
Kernel = kernel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -17,7 +16,7 @@ namespace MediaBrowser.Controller.IO
|
||||
/// modify the directories that the system is watching for changes should use the methods of
|
||||
/// this class to do so. This way we can have the watchers correctly respond to only external changes.
|
||||
/// </summary>
|
||||
public class FileSystemManager : BaseManager<Kernel>
|
||||
public class FileSystemManager : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the directory watchers.
|
||||
@@ -25,23 +24,15 @@ namespace MediaBrowser.Controller.IO
|
||||
/// <value>The directory watchers.</value>
|
||||
private DirectoryWatchers DirectoryWatchers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSystemManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public FileSystemManager(Kernel kernel, ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
||||
: base(kernel)
|
||||
public FileSystemManager(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
_logger = logManager.GetLogger("FileSystemManager");
|
||||
DirectoryWatchers = new DirectoryWatchers(logManager, taskManager, libraryManager, configurationManager);
|
||||
}
|
||||
|
||||
@@ -113,14 +104,17 @@ namespace MediaBrowser.Controller.IO
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool dispose)
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
DirectoryWatchers.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(dispose);
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
MediaBrowser.Controller/IServerApplicationHost.cs
Normal file
10
MediaBrowser.Controller/IServerApplicationHost.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
namespace MediaBrowser.Controller
|
||||
{
|
||||
public interface IServerApplicationHost : IApplicationHost
|
||||
{
|
||||
SystemInfo GetSystemInfo();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
|
||||
namespace MediaBrowser.Controller
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
@@ -11,11 +10,9 @@ using MediaBrowser.Controller.MediaInfo;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Controller.Weather;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -27,7 +24,7 @@ namespace MediaBrowser.Controller
|
||||
/// <summary>
|
||||
/// Class Kernel
|
||||
/// </summary>
|
||||
public class Kernel : BaseKernel, IDisposable
|
||||
public class Kernel : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
@@ -60,12 +57,25 @@ namespace MediaBrowser.Controller
|
||||
public ProviderManager ProviderManager { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kernel context.
|
||||
/// Gets the name of the web application that can be used for url building.
|
||||
/// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
|
||||
/// </summary>
|
||||
/// <value>The kernel context.</value>
|
||||
public override KernelContext KernelContext
|
||||
/// <value>The name of the web application.</value>
|
||||
public string WebApplicationName
|
||||
{
|
||||
get { return KernelContext.Server; }
|
||||
get { return "mediabrowser"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP server URL prefix.
|
||||
/// </summary>
|
||||
/// <value>The HTTP server URL prefix.</value>
|
||||
public virtual string HttpServerUrlPrefix
|
||||
{
|
||||
get
|
||||
{
|
||||
return "http://+:" + _configurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,7 +155,7 @@ namespace MediaBrowser.Controller
|
||||
/// Gets the UDP server port number.
|
||||
/// </summary>
|
||||
/// <value>The UDP server port number.</value>
|
||||
public override int UdpServerPortNumber
|
||||
public int UdpServerPortNumber
|
||||
{
|
||||
get { return 7359; }
|
||||
}
|
||||
@@ -154,6 +164,7 @@ namespace MediaBrowser.Controller
|
||||
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly ILogManager _logManager;
|
||||
private IApplicationHost ApplicationHost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a kernel based on a Data path, which is akin to our current programdata path
|
||||
@@ -164,10 +175,10 @@ namespace MediaBrowser.Controller
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">isoManager</exception>
|
||||
public Kernel(IApplicationHost appHost, IXmlSerializer xmlSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(appHost, logManager, configurationManager)
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
ApplicationHost = appHost;
|
||||
_configurationManager = configurationManager;
|
||||
_xmlSerializer = xmlSerializer;
|
||||
_logManager = logManager;
|
||||
@@ -207,10 +218,8 @@ namespace MediaBrowser.Controller
|
||||
/// Performs initializations that can be reloaded at anytime
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
protected override async void ReloadInternal()
|
||||
public async Task Init()
|
||||
{
|
||||
base.ReloadInternal();
|
||||
|
||||
FindParts();
|
||||
|
||||
await LoadRepositories().ConfigureAwait(false);
|
||||
@@ -306,27 +315,8 @@ namespace MediaBrowser.Controller
|
||||
{
|
||||
DisposeFileSystemManager();
|
||||
|
||||
FileSystemManager = new FileSystemManager(this, _logManager, ApplicationHost.Resolve<ITaskManager>(), ApplicationHost.Resolve<ILibraryManager>(), _configurationManager);
|
||||
FileSystemManager = new FileSystemManager(_logManager, ApplicationHost.Resolve<ITaskManager>(), ApplicationHost.Resolve<ILibraryManager>(), _configurationManager);
|
||||
FileSystemManager.StartWatchers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the system info.
|
||||
/// </summary>
|
||||
/// <returns>SystemInfo.</returns>
|
||||
public override SystemInfo GetSystemInfo()
|
||||
{
|
||||
var info = base.GetSystemInfo();
|
||||
|
||||
var installationManager = ApplicationHost.Resolve<IInstallationManager>();
|
||||
|
||||
if (installationManager != null)
|
||||
{
|
||||
info.InProgressInstallations = installationManager.CurrentInstallations.Select(i => i.Item1).ToArray();
|
||||
info.CompletedInstallations = installationManager.CompletedInstallations.ToArray();
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
<Compile Include="..\SharedVersion.cs">
|
||||
<Link>Properties\SharedVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="BaseManager.cs" />
|
||||
<Compile Include="Configuration\IServerConfigurationManager.cs" />
|
||||
<Compile Include="Drawing\ImageExtensions.cs" />
|
||||
<Compile Include="Drawing\ImageHeader.cs" />
|
||||
@@ -105,6 +104,7 @@
|
||||
<Compile Include="IO\FileSystem.cs" />
|
||||
<Compile Include="IO\FileSystemManager.cs" />
|
||||
<Compile Include="IO\NativeMethods.cs" />
|
||||
<Compile Include="IServerApplicationHost.cs" />
|
||||
<Compile Include="IServerApplicationPaths.cs" />
|
||||
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
|
||||
<Compile Include="Library\DtoBuilder.cs" />
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <summary>
|
||||
/// Class ProviderManager
|
||||
/// </summary>
|
||||
public class ProviderManager : BaseManager<Kernel>
|
||||
public class ProviderManager : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The remote image cache
|
||||
@@ -42,7 +42,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
|
||||
private Kernel Kernel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
|
||||
/// </summary>
|
||||
@@ -50,9 +52,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger, IServerConfigurationManager configurationManager)
|
||||
: base(kernel)
|
||||
{
|
||||
_logger = logger;
|
||||
Kernel = kernel;
|
||||
_httpClient = httpClient;
|
||||
ConfigurationManager = configurationManager;
|
||||
_remoteImageCache = new FileSystemRepository(ImagesDataPath);
|
||||
@@ -354,14 +356,17 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool dispose)
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
_remoteImageCache.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(dispose);
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user