📜  依赖注入在构造函数中创建作用域 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:50.829000             🧑  作者: Mango

代码示例1
public ServiceBusQueueListner(ILogger logger, IServiceProvider serviceProvider, IConfiguration configuration)
        {
            _logger = logger;
            _reportProcessor = serviceProvider.CreateScope().ServiceProvider.GetRequiredService();
            _configuration = configuration;
        }