adic
adic copied to clipboard
Add binding to all interfaces that a given type implements
The idea is to create a binding action that binds to all interfaces of a given type, like:
- a class of name MyClass implements IInterface1, IInterface2, IInterface3.
- to bind all of these interfaces to e.g. a singleton of MyClass, something like
container.BindToInterfaces<MyClass>().ToSingleton<MyClass>()could be done.
The BindToInterfaces<T>() could receive classes or interfaces.
It could be also created a method that bounds to all inherited and implemented types of a given type.
The name of the methods could be BindInterfacesFrom<T>() and BindClassFrom<T>().
This issue could be improved by adding a To() and ToSingleton methods using anonymous functions with a type definition object, so it's possible to create custom To definitions.