I am using structure map and setting up a service based on the profile string passed. I have a list of objects. List of IProcessors
that I need to inject to the RecognizerSaga
to process against each of these processors.
Say, bootstrapping code looks something like this:
x.CreateProfile("A1", p => {
p.Type<IProcessor>().Is.OfConcreteType<TestAProcessor>();
p.Type<IProcessor>().Is.OfConcreteType<TestBProcessor>();
p.Type<IProcessor>().Is.OfConcreteType<TestCProcessor>();
}
x.CreateProfile("B2", p => {
p.Type<IProcessor>().Is.OfConcreteType<TestAProcessor>();
p.Type<IProcessor>().Is.OfConcreteType<TestBProcessor>();
});
When I get these processors I try to build it using ObjectFactory.GetAllInstances<IProductProcessor>
and it returns me all 5 of them though I have setup the default profile as A1. Is there a way to get all instances within a profile. If I say, A1, get me only 3 of them?
For work around I build a factory class which builds object for me, but I would prefer having structuremap all the way.