important ; I am really looking for StructureMap here. Please do not say how to do this with Windsor, Spring, Unity or any of the others .
I play with StructureMap for IoC - and basically my goal is to have a default profile that defines the basic types, and several named profiles that override / extend it. I think profiles can do this, but I just can't get it to work either through xml or with the API code. In particular, if I try to load the container for the profile:
container = new Container(); container.SetDefaultsToProfile(profile);
Then I get "Requested Profile {name} cannot be found", despite the fact that I explicitly called CreateProfile in the initialization (with this name).
Am I barking the wrong tree?
(also posted to user group )
What I ideally want is to define the standard (/ default) types, and then for a number of different named configurations, override some settings - i.e. if i had
- global:
IFoo => Foo , IBar => Bar - configA: (no change)
- configB:
IFoo => SpecialFoo
I believe that this can appear in 2 containers loaded using named profiles. The goal is that if I ask for a container for IBar , I get Bar - but configA returns a Foo (for IFoo ), where - when configB returns SpecialFoo .
Can someone let me know how I can tweak this? Either xml or the code is fine ... I just want it to work. All I need is an interface - concrete mappings (there are no special configuration settings / properties).
Marc gravell
source share