roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
756 stars 113 forks source link

Add ability to inject IPluginConfig<T> #368

Open busheezy opened 6 months ago

busheezy commented 6 months ago

It would be great to be able to inject our config into different services.

roflmuffin commented 6 months ago

This is difficult due to the nature of the OnConfigParsed method which sets an instance of config onto the base plugin after instantation, which occurs much later than service collection creation. We can put the type T from IPluginConfig<T> in the container, but it will not have any modifications that are processed by OnConfigParsed. How does that solution fare?

frederikstonge commented 5 months ago

This would be solved in #400 if we go ahead with the solution.

Let me know what you think.