You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Prism.Wpf with the legacy Unity container and want to migrate to DryIoc.
I want to resolve the following dependencies:
Class1
Service1
MyDbContext (id 1)
Service2
MyDbContext (id 1)
Class2
Service1
MyDbContext (id 2)
Service2
MyDbContext (id 2)
Codewise I want to do something like this:
varcontainer=new Container();
container.Register<Class1>();
container.Register<Class2>();
container.Register<IService1,Service1>();
container.Register<IService2,Service2>();
container.Register<MyDbContext>(reuse: Reuse.Scoped);// Resolve without explicit Scope// Service1 and Service2 should have the same instance of MyDbContext
container.Resolve<Class1>();// Resolve without explicit Scope// Service1 and Service2 should have the same instance of MyDbContext// This instance of MyDbContext should be different than the one of Class1
container.Resolve<Class2>();
In Unity I was able to register a type with new PerResolveLifetimeManager().
In the Microsoft DI, it automatically scopes the Resolve() to the Resolution Root if no scope is provided.
Is this also possible with DryIoc?
I'm thinking of something like a rule WithResolutionRootAsDefaultScope... 😊
P.S.:
In my case, Prism is doing the Resolve() of the types - so I can't create a Scope myself.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi
I'm using
Prism.Wpf
with the legacyUnity
container and want to migrate toDryIoc
.I want to resolve the following dependencies:
Codewise I want to do something like this:
In
Unity
I was able to register a type withnew PerResolveLifetimeManager()
.In the Microsoft DI, it automatically scopes the Resolve() to the Resolution Root if no scope is provided.
Is this also possible with
DryIoc
?I'm thinking of something like a rule
WithResolutionRootAsDefaultScope
... 😊P.S.:
In my case,
Prism
is doing the Resolve() of the types - so I can't create a Scope myself.Beta Was this translation helpful? Give feedback.
All reactions