【发布时间】:2019-10-12 22:53:52
【问题描述】:
基于这个Question Here ,我正在研究将控制器绑定到某些URLs 的解决方案。这些 URL 是在 appsettings.json 中配置的。
由于解决方案是基于装饰器的,我正在寻找一种方法来为装饰器注入 IConfiguration 对象。
示例:
[PortActionConstraint(configuration.GetValue<string>("Product1:Port")]
[Route("api/[controller]")]
[ApiController]
public class Product1Controller : ControllerBase
简而言之,如何将任何接口的 IConfiguration 注入到类装饰器中?
【问题讨论】:
标签: c# asp.net-web-api asp.net-core dependency-injection asp.net-core-2.2