Let's say your container contains many IFrob exports, let's call them Frob1 and Frob2.
If you want all of them you can Locate<IEnumerable<IFrob>>(), which will give you Frob1, Frob2.
Maybe you want to be able to spawn new frobs and locating IEnumerable<Func<IFrob>> does give you two factories. If you .Select(f => f()) then you end up with Frob1, Frob2, as expected.
Now let's say that in addition to that you want each factory to resolve in a new scope. You locate IEnumerable<Func<Scoped<IFrob>>> which returns 2 factories as expected. But (ignoring Dispose for now) if you look at .Select(f => f().Instance) then you'll notice every scoped instance resolves to the same IFrob: Frob2, Frob2 (based on priority, etc.)
It seems to me that Scoped "forgets" what specific IFrob it was supposed to be and just performs a plain Locate<IFrob> again, which is not what I want.
This makes Scoped<IFrob> useless/incompatible with IEnumerable. In fact, just locating IEnumerable<Scoped<IFrob>> returns Frob2, Frob2.
This is a simplified test case. My full code was:
IEnumerable<Meta<Func<string, Scoped<T>>>>
because on top of that I wanted per-IFrob meta information (before invoking the factory; meta infos seem to be right) and named scopes (seems to work ok as well).
Let's say your container contains many
IFrobexports, let's call themFrob1andFrob2.If you want all of them you can
Locate<IEnumerable<IFrob>>(), which will give youFrob1, Frob2.Maybe you want to be able to spawn new frobs and locating
IEnumerable<Func<IFrob>>does give you two factories. If you.Select(f => f())then you end up withFrob1, Frob2, as expected.Now let's say that in addition to that you want each factory to resolve in a new scope. You locate
IEnumerable<Func<Scoped<IFrob>>>which returns 2 factories as expected. But (ignoring Dispose for now) if you look at.Select(f => f().Instance)then you'll notice every scoped instance resolves to the sameIFrob:Frob2, Frob2(based on priority, etc.)It seems to me that
Scoped"forgets" what specificIFrobit was supposed to be and just performs a plainLocate<IFrob>again, which is not what I want.This makes
Scoped<IFrob>useless/incompatible withIEnumerable. In fact, just locatingIEnumerable<Scoped<IFrob>>returnsFrob2, Frob2.This is a simplified test case. My full code was:
IEnumerable<Meta<Func<string, Scoped<T>>>>because on top of that I wanted per-
IFrobmeta information (before invoking the factory; meta infos seem to be right) and named scopes (seems to work ok as well).