Hello Jeremy.
On Saturday, March 16, 2013 9:37:06 PM UTC, Jeremy Miller wrote:
How are you consuming DefaultBus? Are you injecting IBus, or injecting the concrete class? The HttpContextScoped() business is only going to apply to requests for IBus.
All my dependencies are injected through interfaces passed into the constructors. Here are some examples:
public DepartmentCreatedHandler(ISession session, IDepartmentValidationService service, IBus bus) {
Contract.Requires(session != null);
Contract.Requires(service != null);
Contract.Requires(bus != null);
Contract.Ensures(_service != null);
Contract.Ensures(_bus != null);
Contract.Ensures(_session != null);
_session = session;
_service = service;
_bus = bus;
}
public DepartmentController(IBus bus, ISession session) {
Contract.Requires(bus != null);
Contract.Requires(session != null);
Contract.Ensures(_bus != null);
Contract.Ensures(_session != null);
_bus = bus;
_session = session;
}
this web app has several web api services (the last example shows an example of one of those services) which are constructed through an http activator:
public class WebApiActivator : IHttpControllerActivator {
public IHttpController Create(HttpRequestMessage request,
HttpControllerDescriptor controllerDescriptor,
Type controllerType) {
IHttpController controller = null;
try {
controller = (IHttpController) ObjectFactory.GetInstance(controllerType);
}
catch {
}
return controller ??
new DefaultHttpControllerActivator().Create(request, controllerDescriptor, controllerType);
}
}
There are a couple of places where I'm explicitly calling the ObjectFactory method (after adding my registry class, I'm personalizing the IRouter singletone instance with some code that registers the handles for my commands and events), but I'm assuming that getting an instance of an object through ObjectFactory ends up respecting the definitions I've set up on my registry object, right?
btw, any tips on how to debug what's going on?
thanks again.