Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 5fddca1

Browse files
committed
Fix(core): PluginManager DI
1 parent b116269 commit 5fddca1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Core/Interfaces/IPluginManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
namespace SourceSharp.Core.Interfaces;
1+
using System;
2+
3+
namespace SourceSharp.Core.Interfaces;
24

35
internal interface IPluginManager
46
{
5-
void Initialize();
7+
void Initialize(IServiceProvider services);
68
void Shutdown();
79
void Signal();
810

Core/PluginManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using McMaster.NETCore.Plugins;
2-
using Microsoft.Extensions.DependencyInjection;
32
using SourceSharp.Core.Interfaces;
43
using SourceSharp.Core.Models;
54
using SourceSharp.Core.Utils;
@@ -10,21 +9,20 @@
109
using System.Collections.Generic;
1110
using System.IO;
1211
using System.Linq;
12+
using System.Reflection;
1313

1414
namespace SourceSharp.Core;
1515

1616
internal sealed class PluginManager : IPluginManager
1717
{
18-
private readonly IServiceProvider _services;
1918
private readonly ISourceSharpBase _sourceSharp;
2019
private readonly IShareSystemBase _shareSystem;
2120

2221
private readonly List<CPlugin> _plugins;
2322
private readonly List<IListenerBase> _listeners;
2423

25-
public PluginManager(ISourceSharpBase sourceSharp, IShareSystemBase shareSystem, IServiceProvider services)
24+
public PluginManager(ISourceSharpBase sourceSharp, IShareSystemBase shareSystem)
2625
{
27-
_services = services;
2826
_sourceSharp = sourceSharp;
2927
_shareSystem = shareSystem;
3028

@@ -33,8 +31,10 @@ public PluginManager(ISourceSharpBase sourceSharp, IShareSystemBase shareSystem,
3331
}
3432

3533
public void Initialize()
34+
public void Initialize(IServiceProvider services)
3635
{
37-
_listeners.AddRange(_services.GetServices<IListenerBase>());
36+
var listeners = services.GetAllServices<IListenerBase>();
37+
_listeners.AddRange(listeners);
3838

3939
var sourceSharpRoot = Path.Combine(_sourceSharp.GetRootPath(), _sourceSharp.GetGamePath(), "addons", "sourcesharp");
4040

0 commit comments

Comments
 (0)