Skip to content

ToFactory should take in the implementation type #41

@kind-serge

Description

@kind-serge

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions