Remove "extends IHostedService" from classes where it's not required (#236)
Originally, these classes were services because I thought that all DI-resolvable classes need to be services. However, this is not true, so we can make these classes (notably Utility and GuildDataService) not extend anything. `UtilityService` was renamed to `Utility` for simplicity --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
6688481093
commit
bd4c5b26da
11 changed files with 20 additions and 41 deletions
|
@ -11,7 +11,7 @@ namespace Octobot.Services;
|
|||
/// <summary>
|
||||
/// Handles saving, loading, initializing and providing <see cref="GuildData" />.
|
||||
/// </summary>
|
||||
public sealed class GuildDataService : IHostedService
|
||||
public sealed class GuildDataService
|
||||
{
|
||||
private readonly ConcurrentDictionary<Snowflake, GuildData> _datas = new();
|
||||
private readonly ILogger<GuildDataService> _logger;
|
||||
|
@ -24,16 +24,6 @@ public sealed class GuildDataService : IHostedService
|
|||
lifetime.ApplicationStopping.Register(ApplicationStopping);
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken ct)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken ct)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void ApplicationStopping()
|
||||
{
|
||||
SaveAsync(CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
|
Reference in a new issue