In Asp.Net WebApi is GlobalConfig object which consists of DependecyResolver. The DependecyResolver holds information about instances specified by DI framework.
I am just curious if someone has found the way to test the Lifetime of resolved service from this DependecyResolver?
FYI … I’m using Castle.Windsor as DI framework. Implemented in similar way as specified at http://www.asp.net/web-api/overview/extensibility/using-the-web-api-dependency-resolver
Any help appreciated. Thanks.
The difference between MVCs and WebApis
DependencyResolveris that WebApis version has a scope definition. The scope is created when the request arrives and disposed when the request ends.That means that all services which are configured as scoped lives only during the HTTP request/response. (If your IoC container do not bug)
The actual definition can be found here: http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/2be68e50ed73#src%2fSystem.Web.Http%2fDependencies%2fIDependencyResolver.cs