1

私はIDisposabledbコンテキストの周りにデコレータをセットアップしようとしています:

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.DecoratortrackDisposableTransient

4

1 に答える 1