Posts tagged with: autofac
All TagsFound 27 posts tagged with "autofac"
-
Selectively resolving services at runtime with Autofac
This article explains how to selectively resolve a service at runtime with Autofac by making use of the IEnumerable<Lazy<IExport, IExportMetadata>> and Lazy<T, TMetadata> relationship types. It also provides an example of how to refactor the controller constructor to receive the list of exports and how to query the metadata to select the correct export service at runtime.
-
Autofac ASP.NET MVC 4 (Beta) Integration
Autofac 2.6.1 has released a MVC 4 Beta integration, available for download via NuGet, with no breaking changes from the MVC 3 version. The minor change made in the internals allows the lifetime scope applied to a registration to be shared between MVC and the Web API. Users should report any bugs on the issue tracker or ask questions on Stack Overflow using the “autofac” tag.
-
Autofac ASP.NET Web API (Beta) Integration
Autofac has released a beta version of the ASP.NET Web API integration package for NuGet, which supports both web hosting and self hosting scenarios. The integration allows for services to be registered per API controller invocation. A HTTP module style implementation is not required due to the IHttpControllerFactory interface allowing for an abstraction between the two hosting modes. The implementation details are discussed in the article.
-
FilterAttribute Property Injection in Autofac MVC 3 Integration
The mechanism for performing property injection on FilterAttributes via ExtensibleActionInvoker had to be removed due to a bug. The new approach leverages the improved dependency injection support added to MVC 3 and requires calling the RegisterFilterProvider method before building the container and providing it to the AutofacDependencyResolver. A custom FilterAttributeFilterProvider and extension method was added to make this work.
-
View Page Injection in Autofac ASP.NET MVC 3 Integration
ASP.NET MVC 3 provides support for dependency injection on view pages via Autofac, a registration source which allows you to create an adapter that will dynamically provide a registration for a service. Your view pages must inherit from a custom base class and you need to add a registration source called ViewRegistrationSource in the application start event. This allows properties on the view page to be injected by the container.