Jan 11, 2011 at 7:22 AM
Edited Jan 11, 2011 at 7:23 AM
StructureMap has the following lifetime managers:
1. HttpContext which always uses HttpContext (and fails if not running within a web request)
2. HybridHttpOrThreadLocalScoped uses the HttpContext when available. If not, it falls back to caching per thread
It seems Unity does not support these kind of lifetime managers. I found in lab 5 the container is created in the Application_Start with Singleton lifetime configuration for the Logger. The Buildup method inside eventhandler 'Application_PreRequestHandlerExecute'
resolves objects. Is this the way to go for Unity concerning ASP.NET applications?
StructureMap has a Static method which I can use throughout the application, so I do not have to worry about creating/disposing the container, example:
ObjectFactory.Initialize(here I register my mappings);
Logger = ObjectFactory.GetInstance<ILogger>();
As you can see very simple to use and I never have to worry about creating a container. Does Unity have an equivalent or do I always have to create the container first.
Thanks for any help!