Phil Richardson
06/15/2021, 8:53 PMallInstances
method (and associated items for other bind types)?
What exactly is the "all" element of?
All possible instances in the DI container, or all possible according to the Type requested?
The documentation seems lacking, but does seem to imply you are obtaining all possible instances for a given binding type or the specified Type. Even with overrides, your not binding a second instance, as your disallowing the value you are overriding.
Yet at the same time, the documentation also implies you cannot bind the same Type twice, leaving only two possible outcomes from the method. An empty, or a single item list.
Can anybody share more detail on the reasoning on how / when it may return 2 or more items in the list?
Also given this, how does this differentiate to bind/inSet
?
I can see that Sets are very useful and can see a variety of use cases they may help. In this case, yes, it is essentially returning a Set of all the instances bound.
Which brings me back to my original confusion. If Sets provide the multiple binding, where does allInstances fit back into this?romainbsl
06/16/2021, 5:13 AMromainbsl
06/16/2021, 5:17 AMallInstances
is more like an internal API, or it should evolve to provide other options. But, to be short, allInstances<T>
will retrieve a list of all the possible binding matching T
. For example, if you invoke allInstances<Any>
, you might ends up with all the bindings available in the current context.