选项
- 将类从静态更改为实例类(代码省略)
- 通过方法注入提供注入依赖项
public static class XHelper
{
public static TResponse Execute(
string metodo, TRequest request, IConfiguration config)
{
if (config is null) throw new ArgumentNullException("config");
string y = config.apiUrl;
return xxx;
}
}
https://stackoverflow.com/questions/55213803/use-dependency-injection-in-static-class