@ -147,25 +147,20 @@ namespace Emby.Server.Implementations
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
/// <param name="options">Instance of the <see cref="IStartupOptions"/> interface.</param>
/// <param name="startupConfig">The <see cref="IConfiguration" /> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
public ApplicationHost (
IServerApplicationPaths applicationPaths ,
ILoggerFactory loggerFactory ,
IStartupOptions options ,
IConfiguration startupConfig ,
IFileSystem fileSystem ,
IServiceCollection serviceCollection )
IConfiguration startupConfig )
{
ApplicationPaths = applicationPaths ;
LoggerFactory = loggerFactory ;
_startupOptions = options ;
_startupConfig = startupConfig ;
_fileSystemManager = fileSystem ;
ServiceCollection = serviceCollection ;
_fileSystemManager = new ManagedFileSystem ( LoggerFactory . CreateLogger < ManagedFileSystem > ( ) , applicationPaths ) ;
Logger = LoggerFactory . CreateLogger < ApplicationHost > ( ) ;
fileSystem. AddShortcutHandler ( new MbLinkShortcutHandler ( fileSystem) ) ;
_ fileSystemManager . AddShortcutHandler ( new MbLinkShortcutHandler ( _ fileSystemManager ) ) ;
ApplicationVersion = typeof ( ApplicationHost ) . Assembly . GetName ( ) . Version ;
ApplicationVersionString = ApplicationVersion . ToString ( 3 ) ;
@ -230,8 +225,6 @@ namespace Emby.Server.Implementations
/// </summary>
protected ILogger < ApplicationHost > Logger { get ; }
protected IServiceCollection ServiceCollection { get ; }
/// <summary>
/// Gets the logger factory.
/// </summary>
@ -521,7 +514,7 @@ namespace Emby.Server.Implementations
}
/// <inheritdoc/>
public void Init ( )
public void Init ( IServiceCollection serviceCollection )
{
DiscoverTypes ( ) ;
@ -551,128 +544,129 @@ namespace Emby.Server.Implementations
CertificatePath = networkConfiguration . CertificatePath ;
Certificate = GetCertificate ( CertificatePath , networkConfiguration . CertificatePassword ) ;
RegisterServices ( ) ;
RegisterServices ( serviceCollection ) ;
_pluginManager . RegisterServices ( S erviceCollection) ;
_pluginManager . RegisterServices ( s erviceCollection) ;
}
/// <summary>
/// Registers services/resources with the service collection that will be available via DI.
/// </summary>
protected virtual void RegisterServices ( )
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
protected virtual void RegisterServices ( IServiceCollection serviceCollection )
{
S erviceCollection. AddSingleton ( _startupOptions ) ;
s erviceCollection. AddSingleton ( _startupOptions ) ;
S erviceCollection. AddMemoryCache ( ) ;
s erviceCollection. AddMemoryCache ( ) ;
S erviceCollection. AddSingleton < IServerConfigurationManager > ( ConfigurationManager ) ;
S erviceCollection. AddSingleton < IConfigurationManager > ( ConfigurationManager ) ;
S erviceCollection. AddSingleton < IApplicationHost > ( this ) ;
S erviceCollection. AddSingleton < IPluginManager > ( _pluginManager ) ;
S erviceCollection. AddSingleton < IApplicationPaths > ( ApplicationPaths ) ;
s erviceCollection. AddSingleton < IServerConfigurationManager > ( ConfigurationManager ) ;
s erviceCollection. AddSingleton < IConfigurationManager > ( ConfigurationManager ) ;
s erviceCollection. AddSingleton < IApplicationHost > ( this ) ;
s erviceCollection. AddSingleton < IPluginManager > ( _pluginManager ) ;
s erviceCollection. AddSingleton < IApplicationPaths > ( ApplicationPaths ) ;
S erviceCollection. AddSingleton ( _fileSystemManager ) ;
S erviceCollection. AddSingleton < TmdbClientManager > ( ) ;
s erviceCollection. AddSingleton ( _fileSystemManager ) ;
s erviceCollection. AddSingleton < TmdbClientManager > ( ) ;
S erviceCollection. AddSingleton ( NetManager ) ;
s erviceCollection. AddSingleton ( NetManager ) ;
S erviceCollection. AddSingleton < ITaskManager , TaskManager > ( ) ;
s erviceCollection. AddSingleton < ITaskManager , TaskManager > ( ) ;
S erviceCollection. AddSingleton ( _xmlSerializer ) ;
s erviceCollection. AddSingleton ( _xmlSerializer ) ;
S erviceCollection. AddSingleton < IStreamHelper , StreamHelper > ( ) ;
s erviceCollection. AddSingleton < IStreamHelper , StreamHelper > ( ) ;
S erviceCollection. AddSingleton < ICryptoProvider , CryptographyProvider > ( ) ;
s erviceCollection. AddSingleton < ICryptoProvider , CryptographyProvider > ( ) ;
S erviceCollection. AddSingleton < ISocketFactory , SocketFactory > ( ) ;
s erviceCollection. AddSingleton < ISocketFactory , SocketFactory > ( ) ;
S erviceCollection. AddSingleton < IInstallationManager , InstallationManager > ( ) ;
s erviceCollection. AddSingleton < IInstallationManager , InstallationManager > ( ) ;
S erviceCollection. AddSingleton < IZipClient , ZipClient > ( ) ;
s erviceCollection. AddSingleton < IZipClient , ZipClient > ( ) ;
S erviceCollection. AddSingleton < IServerApplicationHost > ( this ) ;
S erviceCollection. AddSingleton < IServerApplicationPaths > ( ApplicationPaths ) ;
s erviceCollection. AddSingleton < IServerApplicationHost > ( this ) ;
s erviceCollection. AddSingleton < IServerApplicationPaths > ( ApplicationPaths ) ;
S erviceCollection. AddSingleton < ILocalizationManager , LocalizationManager > ( ) ;
s erviceCollection. AddSingleton < ILocalizationManager , LocalizationManager > ( ) ;
S erviceCollection. AddSingleton < IBlurayExaminer , BdInfoExaminer > ( ) ;
s erviceCollection. AddSingleton < IBlurayExaminer , BdInfoExaminer > ( ) ;
S erviceCollection. AddSingleton < IUserDataRepository , SqliteUserDataRepository > ( ) ;
S erviceCollection. AddSingleton < IUserDataManager , UserDataManager > ( ) ;
s erviceCollection. AddSingleton < IUserDataRepository , SqliteUserDataRepository > ( ) ;
s erviceCollection. AddSingleton < IUserDataManager , UserDataManager > ( ) ;
S erviceCollection. AddSingleton < IItemRepository , SqliteItemRepository > ( ) ;
s erviceCollection. AddSingleton < IItemRepository , SqliteItemRepository > ( ) ;
S erviceCollection. AddSingleton < IMediaEncoder , MediaBrowser . MediaEncoding . Encoder . MediaEncoder > ( ) ;
S erviceCollection. AddSingleton < EncodingHelper > ( ) ;
s erviceCollection. AddSingleton < IMediaEncoder , MediaBrowser . MediaEncoding . Encoder . MediaEncoder > ( ) ;
s erviceCollection. AddSingleton < EncodingHelper > ( ) ;
// TODO: Refactor to eliminate the circular dependencies here so that Lazy<T> isn't required
S erviceCollection. AddTransient ( provider = > new Lazy < ILibraryMonitor > ( provider . GetRequiredService < ILibraryMonitor > ) ) ;
S erviceCollection. AddTransient ( provider = > new Lazy < IProviderManager > ( provider . GetRequiredService < IProviderManager > ) ) ;
S erviceCollection. AddTransient ( provider = > new Lazy < IUserViewManager > ( provider . GetRequiredService < IUserViewManager > ) ) ;
S erviceCollection. AddSingleton < ILibraryManager , LibraryManager > ( ) ;
s erviceCollection. AddTransient ( provider = > new Lazy < ILibraryMonitor > ( provider . GetRequiredService < ILibraryMonitor > ) ) ;
s erviceCollection. AddTransient ( provider = > new Lazy < IProviderManager > ( provider . GetRequiredService < IProviderManager > ) ) ;
s erviceCollection. AddTransient ( provider = > new Lazy < IUserViewManager > ( provider . GetRequiredService < IUserViewManager > ) ) ;
s erviceCollection. AddSingleton < ILibraryManager , LibraryManager > ( ) ;
S erviceCollection. AddSingleton < IMusicManager , MusicManager > ( ) ;
s erviceCollection. AddSingleton < IMusicManager , MusicManager > ( ) ;
S erviceCollection. AddSingleton < ILibraryMonitor , LibraryMonitor > ( ) ;
s erviceCollection. AddSingleton < ILibraryMonitor , LibraryMonitor > ( ) ;
S erviceCollection. AddSingleton < ISearchEngine , SearchEngine > ( ) ;
s erviceCollection. AddSingleton < ISearchEngine , SearchEngine > ( ) ;
S erviceCollection. AddSingleton < IWebSocketManager , WebSocketManager > ( ) ;
s erviceCollection. AddSingleton < IWebSocketManager , WebSocketManager > ( ) ;
S erviceCollection. AddSingleton < IImageProcessor , ImageProcessor > ( ) ;
s erviceCollection. AddSingleton < IImageProcessor , ImageProcessor > ( ) ;
S erviceCollection. AddSingleton < ITVSeriesManager , TVSeriesManager > ( ) ;
s erviceCollection. AddSingleton < ITVSeriesManager , TVSeriesManager > ( ) ;
S erviceCollection. AddSingleton < IMediaSourceManager , MediaSourceManager > ( ) ;
s erviceCollection. AddSingleton < IMediaSourceManager , MediaSourceManager > ( ) ;
S erviceCollection. AddSingleton < ISubtitleManager , SubtitleManager > ( ) ;
s erviceCollection. AddSingleton < ISubtitleManager , SubtitleManager > ( ) ;
S erviceCollection. AddSingleton < IProviderManager , ProviderManager > ( ) ;
s erviceCollection. AddSingleton < IProviderManager , ProviderManager > ( ) ;
// TODO: Refactor to eliminate the circular dependency here so that Lazy<T> isn't required
S erviceCollection. AddTransient ( provider = > new Lazy < ILiveTvManager > ( provider . GetRequiredService < ILiveTvManager > ) ) ;
S erviceCollection. AddSingleton < IDtoService , DtoService > ( ) ;
s erviceCollection. AddTransient ( provider = > new Lazy < ILiveTvManager > ( provider . GetRequiredService < ILiveTvManager > ) ) ;
s erviceCollection. AddSingleton < IDtoService , DtoService > ( ) ;
S erviceCollection. AddSingleton < IChannelManager , ChannelManager > ( ) ;
s erviceCollection. AddSingleton < IChannelManager , ChannelManager > ( ) ;
S erviceCollection. AddSingleton < ISessionManager , SessionManager > ( ) ;
s erviceCollection. AddSingleton < ISessionManager , SessionManager > ( ) ;
S erviceCollection. AddSingleton < IDlnaManager , DlnaManager > ( ) ;
s erviceCollection. AddSingleton < IDlnaManager , DlnaManager > ( ) ;
S erviceCollection. AddSingleton < ICollectionManager , CollectionManager > ( ) ;
s erviceCollection. AddSingleton < ICollectionManager , CollectionManager > ( ) ;
S erviceCollection. AddSingleton < IPlaylistManager , PlaylistManager > ( ) ;
s erviceCollection. AddSingleton < IPlaylistManager , PlaylistManager > ( ) ;
S erviceCollection. AddSingleton < ISyncPlayManager , SyncPlayManager > ( ) ;
s erviceCollection. AddSingleton < ISyncPlayManager , SyncPlayManager > ( ) ;
S erviceCollection. AddSingleton < LiveTvDtoService > ( ) ;
S erviceCollection. AddSingleton < ILiveTvManager , LiveTvManager > ( ) ;
s erviceCollection. AddSingleton < LiveTvDtoService > ( ) ;
s erviceCollection. AddSingleton < ILiveTvManager , LiveTvManager > ( ) ;
S erviceCollection. AddSingleton < IUserViewManager , UserViewManager > ( ) ;
s erviceCollection. AddSingleton < IUserViewManager , UserViewManager > ( ) ;
S erviceCollection. AddSingleton < INotificationManager , NotificationManager > ( ) ;
s erviceCollection. AddSingleton < INotificationManager , NotificationManager > ( ) ;
S erviceCollection. AddSingleton < IDeviceDiscovery , DeviceDiscovery > ( ) ;
s erviceCollection. AddSingleton < IDeviceDiscovery , DeviceDiscovery > ( ) ;
S erviceCollection. AddSingleton < IChapterManager , ChapterManager > ( ) ;
s erviceCollection. AddSingleton < IChapterManager , ChapterManager > ( ) ;
S erviceCollection. AddSingleton < IEncodingManager , MediaEncoder . EncodingManager > ( ) ;
s erviceCollection. AddSingleton < IEncodingManager , MediaEncoder . EncodingManager > ( ) ;
S erviceCollection. AddScoped < ISessionContext , SessionContext > ( ) ;
s erviceCollection. AddScoped < ISessionContext , SessionContext > ( ) ;
S erviceCollection. AddSingleton < IAuthService , AuthService > ( ) ;
S erviceCollection. AddSingleton < IQuickConnect , QuickConnectManager > ( ) ;
s erviceCollection. AddSingleton < IAuthService , AuthService > ( ) ;
s erviceCollection. AddSingleton < IQuickConnect , QuickConnectManager > ( ) ;
S erviceCollection. AddSingleton < ISubtitleEncoder , MediaBrowser . MediaEncoding . Subtitles . SubtitleEncoder > ( ) ;
s erviceCollection. AddSingleton < ISubtitleEncoder , MediaBrowser . MediaEncoding . Subtitles . SubtitleEncoder > ( ) ;
S erviceCollection. AddSingleton < IAttachmentExtractor , MediaBrowser . MediaEncoding . Attachments . AttachmentExtractor > ( ) ;
s erviceCollection. AddSingleton < IAttachmentExtractor , MediaBrowser . MediaEncoding . Attachments . AttachmentExtractor > ( ) ;
S erviceCollection. AddSingleton < TranscodingJobHelper > ( ) ;
S erviceCollection. AddScoped < MediaInfoHelper > ( ) ;
S erviceCollection. AddScoped < AudioHelper > ( ) ;
S erviceCollection. AddScoped < DynamicHlsHelper > ( ) ;
s erviceCollection. AddSingleton < TranscodingJobHelper > ( ) ;
s erviceCollection. AddScoped < MediaInfoHelper > ( ) ;
s erviceCollection. AddScoped < AudioHelper > ( ) ;
s erviceCollection. AddScoped < DynamicHlsHelper > ( ) ;
S erviceCollection. AddSingleton < IDirectoryService , DirectoryService > ( ) ;
s erviceCollection. AddSingleton < IDirectoryService , DirectoryService > ( ) ;
}
/// <summary>