1
1
using McMaster . NETCore . Plugins ;
2
- using Microsoft . Extensions . DependencyInjection ;
3
2
using SourceSharp . Core . Interfaces ;
4
3
using SourceSharp . Core . Models ;
5
4
using SourceSharp . Core . Utils ;
10
9
using System . Collections . Generic ;
11
10
using System . IO ;
12
11
using System . Linq ;
12
+ using System . Reflection ;
13
13
14
14
namespace SourceSharp . Core ;
15
15
16
16
internal sealed class PluginManager : IPluginManager
17
17
{
18
- private readonly IServiceProvider _services ;
19
18
private readonly ISourceSharpBase _sourceSharp ;
20
19
private readonly IShareSystemBase _shareSystem ;
21
20
22
21
private readonly List < CPlugin > _plugins ;
23
22
private readonly List < IListenerBase > _listeners ;
24
23
25
- public PluginManager ( ISourceSharpBase sourceSharp , IShareSystemBase shareSystem , IServiceProvider services )
24
+ public PluginManager ( ISourceSharpBase sourceSharp , IShareSystemBase shareSystem )
26
25
{
27
- _services = services ;
28
26
_sourceSharp = sourceSharp ;
29
27
_shareSystem = shareSystem ;
30
28
@@ -33,8 +31,10 @@ public PluginManager(ISourceSharpBase sourceSharp, IShareSystemBase shareSystem,
33
31
}
34
32
35
33
public void Initialize ( )
34
+ public void Initialize ( IServiceProvider services )
36
35
{
37
- _listeners . AddRange ( _services . GetServices < IListenerBase > ( ) ) ;
36
+ var listeners = services . GetAllServices < IListenerBase > ( ) ;
37
+ _listeners . AddRange ( listeners ) ;
38
38
39
39
var sourceSharpRoot = Path . Combine ( _sourceSharp . GetRootPath ( ) , _sourceSharp . GetGamePath ( ) , "addons" , "sourcesharp" ) ;
40
40
0 commit comments