-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I've been trying to figure out how to properly use AutoFac and I think I'm almost there, but I've hit one final snag that I'm struggling with.
Inside of AutoFacRegistrations.cs, I've got:
//containerBuilder.Register(x => new NHibernateDaoFactory()).As().SingleInstance();
//containerBuilder.RegisterType().As().SingleInstance();
// TODO: Still not really sure why I need InstancePerApiRequest here. Figure it out! Maybe if I removed the need to pass params into ManagerFactory it'll be OK
containerBuilder.RegisterType().As().InstancePerApiRequest();
containerBuilder.RegisterType().As().InstancePerApiRequest();
It should be possible (and is best practice) to only instantiate a single instance of a Factory. However, my test cases fail when I try to use SingleInstance.
For reference:
http://codereview.stackexchange.com/questions/44170/should-a-factory-ever-be-generated-per-request