using System;
using Jellyfin.Plugin.WatchedTogether.Auth;
using Jellyfin.Plugin.WatchedTogether.Services;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.DependencyInjection;
namespace Jellyfin.Plugin.WatchedTogether;
///
/// Registers the plugin's services with the host.
///
public class ServiceRegistrator : IPluginServiceRegistrator
{
///
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
// The auth provider takes these lazily so the container can build it while IUserManager is
// still under construction; see SharedAccountAuthenticationProvider's constructor remarks.
// Microsoft's container has no built-in Lazy support, so the factories are explicit.
serviceCollection.AddSingleton(
provider => new Lazy(provider.GetRequiredService));
serviceCollection.AddSingleton(
provider => new Lazy(provider.GetRequiredService));
// Discovered by Jellyfin and matched to shared accounts via User.AuthenticationProviderId.
serviceCollection.AddSingleton();
serviceCollection.AddHostedService();
serviceCollection.AddHostedService();
}
}