fix 2
This commit is contained in:
@@ -16,14 +16,20 @@ 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>>()));
|
||||
|
||||
// The path is resolved inside the factory (not eagerly here) because the host's service
|
||||
// provider does not exist yet while RegisterServices is running.
|
||||
serviceCollection.AddSingleton(sp =>
|
||||
{
|
||||
var dbPath = Path.Combine(
|
||||
sp.GetRequiredService<IApplicationPaths>().PluginConfigurationsPath,
|
||||
"RedditComments",
|
||||
"reddit-comments.db");
|
||||
return new CommentCache(dbPath, sp.GetRequiredService<ILogger<CommentCache>>());
|
||||
});
|
||||
|
||||
serviceCollection.AddSingleton(sp => new RedditCommentsService(
|
||||
sp.GetRequiredService<ILogger<RedditCommentsService>>(),
|
||||
sp.GetRequiredService<RedditClient>(),
|
||||
|
||||
Reference in New Issue
Block a user