Hey Aaron,
Yes, that’s a problem that having a container at the core will trigger. This is the same problem if I want to switch to supporting array types in constructors, as Windsor doesn’t support that by default. I’m not however entirely sure how we can solve this issue...
Maybe for those containers that support sub containers we could create a sub container when we associate with the container, and add our customizations there. I tried and failed with Windsor, but I know autofac has support for them. What about ninject?
In the end though, I don’t think there’s much we can do. If one wants to use their own container, it has to support a few features, which means customizing the container. If that’s not possible, then one could just live with two containers, and use some factory support in the destination container to pull objects from openrasta using the service locator. Maybe that’s something to consider as a potential avenue to think about?
Seb
Hey Aaron,
Yes, that’s a problem that having a container at the core will trigger. This is the same problem if I want to switch to supporting array types in constructors, as Windsor doesn’t support that by default. I’m not however entirely sure how we can solve this issue...
The thing with the Windsor container is that subcontainers can look “up”, but once they’re up there they can’t look down.
There are two scenarios, and only one would work at all.
Scenario 1:
- The fluent API registers the handler in the sub container
- The handler depends on IRequest, so that resolves in the same sub container
- All is good
Scenario 2:
- The handler is registered in the root container
- It depends on IRequest, the request is defined in the sub container
- No good
Scenario 3:
- The handler is registered in the sub container
- The handler depends on a service the user registered in the root container
- The service depends on something from openrasta, and as such in the sub container
- No good.
All in all, I think there’s always going to be a problem with making this work equally across containers, but it’s a lesser than two evils, the other option being having one container for openrasta and one for the rest. I don’t believe it’s the right way to go.
My personal preference is that those problems are not major enough to be a problem for most, and if it is a problem, they have an option to use a different container and loose the ability to access components both ways (which is the evil case i don’t want to make the default :) )