-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginManifest.cs
61 lines (49 loc) · 1.53 KB
/
PluginManifest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.Extensions.DependencyInjection;
using JetBrains.Annotations;
using YumeChan.DreamJockey.Data;
using YumeChan.DreamJockey.Services;
using YumeChan.PluginBase;
using YumeChan.PluginBase.Tools;
namespace YumeChan.DreamJockey;
/// <summary>
/// Plugin Manifest for DreamJockey
/// </summary>
[UsedImplicitly]
public class PluginManifest : Plugin
{
internal const string GlobalConfigFilename = "global-config.json";
private readonly IdleInstancesCullingHandler _cullingHandler;
public override string DisplayName => "YumeChan DreamJockey";
public override bool StealthMode => false;
public PluginManifest(IdleInstancesCullingHandler cullingHandler)
{
_cullingHandler = cullingHandler;
}
public override async Task LoadAsync()
{
CancellationToken ct = CancellationToken.None;
await _cullingHandler.StartAsync(ct);
await base.LoadAsync();
}
public override async Task UnloadAsync()
{
CancellationToken ct = CancellationToken.None;
await _cullingHandler.StopAsync(ct);
await base.UnloadAsync();
}
}
public sealed class Dependencies : DependencyInjectionHandler
{
public override IServiceCollection ConfigureServices(IServiceCollection services)
{
services.AddSingleton(static services => services
.GetRequiredService<IInterfaceConfigProvider<IPluginConfig>>()
.InitConfig(PluginManifest.GlobalConfigFilename)
.PopulateConfig()
);
services.AddSingleton<IdleInstancesCullingHandler>();
services.AddSingleton<MusicPlayerService>();
services.AddSingleton<MusicQueueService>();
return services;
}
}