You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I register multiple implementations for the same interface - but do it individually one by one, the unnamed one (if present) isn't resolved when using constructor injection of IEnumerable. On the other hand, it works when using ResolveAll method.
the last row invokes method with last parameter set to false . This parameter is actually includeUnnamed parameter in ResolveAll method. When ResolveAll is called directly (as in fisrst example) it falls to default call, where includeUnnamed is set to true. That's why it works in first example, but doesn't work in second.
My question is - is that a purpose ? If so, can you examplain me why?
Thanks,
Patrik
The text was updated successfully, but these errors were encountered:
I'm really not sure on that one, but to me it should be resolved as that's the behavior I've seen with the new Microsoft di. Can you create some tests covering all scenarios and add a pr for this.
Hi guys,
I found out the following issue:
When I register multiple implementations for the same interface - but do it individually one by one, the unnamed one (if present) isn't resolved when using constructor injection of IEnumerable. On the other hand, it works when using ResolveAll method.
Consider following registration example:
TinyIoCContainer.Current.Register<Interface, Impl1>(); TinyIoCContainer.Current.Register<Interface, Impl2>("2");
When calling
TinyIoCContainer.Current.ResolveAll<Interface>();
resulting list contains both of registered implementations. But if it's used this way:
TinyIoCContainer.Current.Resolve<CtorTest>();
where class CtorTest looks like this:
`
public class CtorTest
{
`
resulting list contains only named registrations. When I was digging in sources, I found out that in following method:
`
private object GetIEnumerableRequest(Type type)
{
`
the last row invokes method with last parameter set to
false
. This parameter is actually includeUnnamed parameter in ResolveAll method. When ResolveAll is called directly (as in fisrst example) it falls to default call, where includeUnnamed is set to true. That's why it works in first example, but doesn't work in second.My question is - is that a purpose ? If so, can you examplain me why?
Thanks,
Patrik
The text was updated successfully, but these errors were encountered: