내가 IDisposable
dB 문맥 주위 설정에 장식을하려고 해요 : 내가 마지막 행의 주석을 해제하면DryIoc : 등록하는 방법을 알아낼 수는 IDisposable 데코레이터 객체
c.Register<IContext, DbContext>(setup: Setup.With(trackDisposableTransient: true));
// c.Register<IContext, ConsoleTimedContext>(setup: Setup.Decorator);
가 프로그램 예외 :
DryIoc.ContainerException: Registered Disposable Transient service Lib.DI.IContext with key {no key} and factory container won't be disposed by container. DryIoc does not hold reference to resolved transients, and therefore does not control their dispose. To silence this exception Register<YourService>(setup: Setup.With(allowDisposableTransient: true)) or set the rule Container(rules => rules.WithoutThrowOnRegisteringDisposableTransient()). To enable tracking use Register<YourService>(setup: Setup.With(trackDisposableTransient: true)) or set the rule Container(rules => rules.WithTrackingDisposableTransient()) à DryIoc.Throw.It(Int32 error, Object arg0, Object arg1, Object arg2, Object arg3) à DryIoc.Container.ThrowIfInvalidRegistration(Factory factory, Type serviceType, Object serviceKey, Boolean isStaticallyChecked) à DryIoc.Container.Register(Factory factory, Type serviceType, Object serviceKey, IfAlreadyRegistered ifAlreadyRegistered, Boolean isStaticallyChecked) à DryIoc.Registrator.Register[TService,TImplementation](IRegistrator registrator, IReuse reuse, Made made, Setup setup, IfAlreadyRegistered ifAlreadyRegistered, Object serviceKey)
Setup.Decorator
과 trackDisposableTransient
의 혼합 방법은 무엇입니까?
을, 그래서 당신은 어떻게 설명 될까요? 부작용은 무엇입니까? –
과도기 추적 기능은 다소 논쟁의 여지가 있으며 처음에는 새로운 .NET 코어 MS.DI를 준수하기 위해 도입되었습니다. 그래서 가능한 한 제한적으로 만들었습니다. decotators (희망에 따라)에 이것을 추가하는 것은 문제가되지 않습니다. 그러나 먼저 질문 : 당신의 장식 서비스가 재사용되고 있습니까? – dadhi
DI 컨텍스트에서 _reused_의 의미가 확실하지 않지만 db를 쿼리 할 때마다 사용됩니다. –