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

ToFactory should take in the implementation type #41

Open
kind-serge opened this issue Jan 4, 2018 · 0 comments
Open

ToFactory should take in the implementation type #41

kind-serge opened this issue Jan 4, 2018 · 0 comments

Comments

@kind-serge
Copy link

With current design an end user must bind both a factory interface to a factory and the result interface to a concrete type:

kernel.Bind<IFooFactory>().ToFactory();
kernel.Bind<IFoo>().To<Foo>();

This creates a danger (actually have happened) of ability to inject IFoo directly bypassing the factory just because its interface binding is required for the factory to work.
Ideally, in such cases the extension method should be ToFactoryOf<Foo>() or ToFactory().Of<Foo>() which allows explicitly specify the implementation type without a necessity to bind it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant