important; I'm really looking for a StructureMap
answer here. Please don't say how to do it with Windsor, Spring, Unity, or any of the others.
I'm playing with StructureMap
for IoC - and basically my aim is to have a "default" profile that defines the core types, and a number of named profiles that override/extend this. I think that profiles can do this, but I simply can't get it to work either through the xml or the code APIs. In particular, if I try to load a container for a profile:
container = new Container();
container.SetDefaultsToProfile(profile);
Then I get "Requested Profile {name} cannot be found", despite the fact that I clearly called CreateProfile
in the initialize (with that name).
Am I barking up the wrong tree?
(also posted to user-group)
What I ideally want is to be able to define the standard (/default) types, and then for a range of different named configurations, override some of the settings - i.e. if I had
- global:
IFoo
=>Foo
,IBar
=>Bar
- configA: (no changes)
- configB:
IFoo
=>SpecialFoo
I believe this could map to 2 containers, loaded using named profiles.
The purpose being that if I ask either container for an IBar
, I get a
Bar
- but configA returns a Foo
(for IFoo
), where-as configB returns a
SpecialFoo
.
Can somebody give me a clue how I can configure this? Either xml or code is fine... I just want it to work. All I need is interface-to- concrete-type mappings (no special config/property settings).