public TestService(TestTransient testTransient, TestSingleton testSingleton, IFactory <TestTransient> transientFactory, IFactory <TestSingleton> singletonFactory) { TestTransient = testTransient; TestSingleton = testSingleton; TransientFactory = transientFactory; SingletonFactory = singletonFactory; }
public IndexModel(ILogger <IndexModel> logger, TestScope _testScope, TestSingleton _testSingleton, TestTransient _testTransient, IServiceProvider provider) { _logger = logger; this._testScope = _testScope; this._testSingleton = _testSingleton; this._testTransient = _testTransient; //此处拿到的IServiceProvider是每个请求生成的IServiceProvider,所有的scope和transient生命周期的都由这个类生成 this._serviceProvider = provider; }