init
This commit is contained in:
34
Jellyfin.Plugin.RedditComments/PluginServiceRegistrator.cs
Normal file
34
Jellyfin.Plugin.RedditComments/PluginServiceRegistrator.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.IO;
|
||||
using Jellyfin.Plugin.RedditComments.Services;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.RedditComments;
|
||||
|
||||
/// <summary>
|
||||
/// Registers the plugin's services in the Jellyfin DI container.
|
||||
/// </summary>
|
||||
public class PluginServiceRegistrator : IPluginServiceRegistrator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
||||
{
|
||||
var dbPath = Path.Combine(
|
||||
applicationHost.Resolve<IApplicationPaths>().PluginConfigurationsPath,
|
||||
"RedditComments",
|
||||
"reddit-comments.db");
|
||||
|
||||
serviceCollection.AddSingleton<RateLimiter>();
|
||||
serviceCollection.AddSingleton(sp => new RedditClient(sp.GetRequiredService<ILogger<RedditClient>>(), sp.GetRequiredService<RateLimiter>()));
|
||||
serviceCollection.AddSingleton(sp => new CommentCache(dbPath, sp.GetRequiredService<ILogger<CommentCache>>()));
|
||||
serviceCollection.AddSingleton(sp => new RedditCommentsService(
|
||||
sp.GetRequiredService<ILogger<RedditCommentsService>>(),
|
||||
sp.GetRequiredService<RedditClient>(),
|
||||
sp.GetRequiredService<CommentCache>()));
|
||||
|
||||
serviceCollection.AddHostedService<WebScriptInjector>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user