OpenScope changes #401
Unanswered
timrhaynes
asked this question in
Q&A
Replies: 1 comment 5 replies
-
@timrhaynes The direct rewrite would be something like this: public IContainer OpenScope(string scopeName)
{
var container = _internalDryContainer.OpenScope(scopeName).Resolve<IContainer>(); // see the Resolve here!
container.Register<IScopedDIContainer, DIContainer>(Reuse.InCurrentScope,
Made.Of(FactoryMethod.ConstructorWithResolvableArgumentsIncludingNonPublic), ifAlreadyRegistered: IfAlreadyRegistered.Replace);
return container.Resolve<IScopedDIContainer>();
} But additionally I would use the public IContainer OpenScope(string scopeName)
{
var scope = _internalDryContainer.OpenScope(scopeName);
var diContainer = new DiContainer();
scope.Use<IScopedDIContainer>(new DiContainer());
return diContainer;
} |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In DryIoc 2.12.10, OpenScope returns an IContainer, but in DryIoc 4.7.5, OpenScope returns an IResolverContext.
How would I rewrite this method to work properly under 4.7.5?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions