< Summary - Jellyfin

Information
Class: Jellyfin.Server.CoreAppHost
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/CoreAppHost.cs
Line coverage
94%
Covered lines: 34
Uncovered lines: 2
Coverable lines: 36
Total lines: 126
Line coverage: 94.4%
Branch coverage
62%
Covered branches: 5
Total branches: 8
Branch coverage: 62.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
RegisterServices(...)62.5%8.02893.33%

File(s)

/srv/git/jellyfin/Jellyfin.Server/CoreAppHost.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Reflection;
 4using Emby.Server.Implementations;
 5using Emby.Server.Implementations.Session;
 6using Jellyfin.Api.WebSocketListeners;
 7using Jellyfin.Drawing;
 8using Jellyfin.Drawing.Skia;
 9using Jellyfin.LiveTv;
 10using Jellyfin.Server.Implementations;
 11using Jellyfin.Server.Implementations.Activity;
 12using Jellyfin.Server.Implementations.Devices;
 13using Jellyfin.Server.Implementations.Events;
 14using Jellyfin.Server.Implementations.Security;
 15using Jellyfin.Server.Implementations.Trickplay;
 16using Jellyfin.Server.Implementations.Users;
 17using MediaBrowser.Controller;
 18using MediaBrowser.Controller.Authentication;
 19using MediaBrowser.Controller.BaseItemManager;
 20using MediaBrowser.Controller.Devices;
 21using MediaBrowser.Controller.Drawing;
 22using MediaBrowser.Controller.Events;
 23using MediaBrowser.Controller.Library;
 24using MediaBrowser.Controller.Lyrics;
 25using MediaBrowser.Controller.Net;
 26using MediaBrowser.Controller.Security;
 27using MediaBrowser.Controller.Trickplay;
 28using MediaBrowser.Model.Activity;
 29using MediaBrowser.Providers.Lyric;
 30using Microsoft.Extensions.Configuration;
 31using Microsoft.Extensions.DependencyInjection;
 32using Microsoft.Extensions.Logging;
 33
 34namespace Jellyfin.Server
 35{
 36    /// <summary>
 37    /// Implementation of the abstract <see cref="ApplicationHost" /> class.
 38    /// </summary>
 39    public class CoreAppHost : ApplicationHost
 40    {
 41        /// <summary>
 42        /// Initializes a new instance of the <see cref="CoreAppHost" /> class.
 43        /// </summary>
 44        /// <param name="applicationPaths">The <see cref="ServerApplicationPaths" /> to be used by the <see cref="CoreAp
 45        /// <param name="loggerFactory">The <see cref="ILoggerFactory" /> to be used by the <see cref="CoreAppHost" />.<
 46        /// <param name="options">The <see cref="StartupOptions" /> to be used by the <see cref="CoreAppHost" />.</param
 47        /// <param name="startupConfig">The <see cref="IConfiguration" /> to be used by the <see cref="CoreAppHost" />.<
 48        public CoreAppHost(
 49            IServerApplicationPaths applicationPaths,
 50            ILoggerFactory loggerFactory,
 51            IStartupOptions options,
 52            IConfiguration startupConfig)
 2253            : base(
 2254                applicationPaths,
 2255                loggerFactory,
 2256                options,
 2257                startupConfig)
 58        {
 2259        }
 60
 61        /// <inheritdoc/>
 62        protected override void RegisterServices(IServiceCollection serviceCollection)
 63        {
 64            // Register an image encoder
 2265            bool useSkiaEncoder = SkiaEncoder.IsNativeLibAvailable();
 2266            Type imageEncoderType = useSkiaEncoder
 2267                ? typeof(SkiaEncoder)
 2268                : typeof(NullImageEncoder);
 2269            serviceCollection.AddSingleton(typeof(IImageEncoder), imageEncoderType);
 70
 71            // Log a warning if the Skia encoder could not be used
 2272            if (!useSkiaEncoder)
 73            {
 074                Logger.LogWarning("Skia not available. Will fallback to {ImageEncoder}.", nameof(NullImageEncoder));
 75            }
 76
 2277            serviceCollection.AddEventServices();
 2278            serviceCollection.AddSingleton<IBaseItemManager, BaseItemManager>();
 2279            serviceCollection.AddSingleton<IEventManager, EventManager>();
 80
 2281            serviceCollection.AddSingleton<IActivityManager, ActivityManager>();
 2282            serviceCollection.AddSingleton<IUserManager, UserManager>();
 2283            serviceCollection.AddSingleton<IAuthenticationProvider, DefaultAuthenticationProvider>();
 2284            serviceCollection.AddSingleton<IAuthenticationProvider, InvalidAuthProvider>();
 2285            serviceCollection.AddSingleton<IPasswordResetProvider, DefaultPasswordResetProvider>();
 2286            serviceCollection.AddScoped<IDisplayPreferencesManager, DisplayPreferencesManager>();
 2287            serviceCollection.AddSingleton<IDeviceManager, DeviceManager>();
 2288            serviceCollection.AddSingleton<ITrickplayManager, TrickplayManager>();
 89
 90            // TODO search the assemblies instead of adding them manually?
 2291            serviceCollection.AddSingleton<IWebSocketListener, SessionWebSocketListener>();
 2292            serviceCollection.AddSingleton<IWebSocketListener, ActivityLogWebSocketListener>();
 2293            serviceCollection.AddSingleton<IWebSocketListener, ScheduledTasksWebSocketListener>();
 2294            serviceCollection.AddSingleton<IWebSocketListener, SessionInfoWebSocketListener>();
 95
 2296            serviceCollection.AddSingleton<IAuthorizationContext, AuthorizationContext>();
 97
 2298            serviceCollection.AddScoped<IAuthenticationManager, AuthenticationManager>();
 99
 44100            foreach (var type in GetExportTypes<ILyricProvider>())
 101            {
 0102                serviceCollection.AddSingleton(typeof(ILyricProvider), type);
 103            }
 104
 132105            foreach (var type in GetExportTypes<ILyricParser>())
 106            {
 44107                serviceCollection.AddSingleton(typeof(ILyricParser), type);
 108            }
 109
 22110            base.RegisterServices(serviceCollection);
 22111        }
 112
 113        /// <inheritdoc />
 114        protected override IEnumerable<Assembly> GetAssembliesWithPartsInternal()
 115        {
 116            // Jellyfin.Server
 117            yield return typeof(CoreAppHost).Assembly;
 118
 119            // Jellyfin.Server.Implementations
 120            yield return typeof(JellyfinDbContext).Assembly;
 121
 122            // Jellyfin.LiveTv
 123            yield return typeof(LiveTvManager).Assembly;
 124        }
 125    }
 126}