lwl1569  

选项

  1. 将类从静态更改为实例类(代码省略)
  2. 通过方法注入提供注入依赖项
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

posted on 2021-10-03 22:43  lwl1569  阅读(199)  评论(0编辑  收藏  举报