Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify injecting Func<T> factory delegates for cross wired components #715

Open
dotnetjunkie opened this issue May 16, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@dotnetjunkie
Copy link
Collaborator

commented May 16, 2019

#711 brings up an interesting point: it would be useful to improve cross wiring to allow Func<T> dependencies to be injected, when T is an available framework service to cross-wire. In Simple Injector, the Func<T> can be a singleton, which allows a scoped or transient service to be resolved from an (implicitly created) IServiceScope.

The simplified example goes as follows:

container.RegisterInstance<Func<T>>(
    () => container.GetInstance<IServiceScope>().ServiceProvider.GetRequiredService<T>());

@dotnetjunkie dotnetjunkie added this to the Backlog milestone May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.