Tag: autofac
All the articles with the tag "autofac".
ASP.NET MVC 3 Beta integration for Autofac
Published:5 min readThe Autofac MVC integration has been updated to provide integration with the ASP.NET MVC 3 Beta, making it easier for users by removing the need to add a reference to the Autofac.Integration.Web.dll assembly, implement the IContainerProviderAccessor interface on the HttpApplication, and register the ContainerDisposalModule in the web.config file. The core piece of the integration is the AutofacDependencyResolver which is an implementation of the IDependencyResolver interface that Brad Wilson outlines in his blog post series on ASP.NET MVC 3 Service Location. A HTTP module called RequestLifetimeModule is registered programmatically via the DynamicModuleUtility class to inform Autofac when the HTTP request has ended.
Introducing Action Injection with Autofac ASP.NET MVC Integration
Published:7 min readAutofac ASP.NET MVC Integration has introduced a new approach to dependency injection called Action Injection, which allows dependencies to be injected into action methods instead of the controller's constructor. This makes it easier to provide mock implementations for unit testing and reduces the number of mocks required.
Making Self-Hosting with Autofac WCF Integration easier
Published:2 min readThis article explains how to use the Autofac WCF integration to make self-hosting WCF services easier. It provides code to extend ServiceHost with a new method called AddDependencyInjectionBehavior which takes an IContainer instance as an argument. This makes the code more concise and eliminates the need to write a separate helper method.
Self-Hosting WCF Services with the Autofac WCF Integration
Published:2 min readThis post provides a demonstration of how to use Autofac's WCF Integration to self-host a web service with a dependency that is injected through the WCF extensibility points. An example and instructions on how to create a client proxy are provided.
Autofac 2.0 Podcast
Published:1 min readNicholas Blumhardt talks about Autofac 2 on the Talking Shop Down Under podcast and can also be heard speaking about Autofac on the .NET Rocks! podcast. He discusses IoC containers in general, the service locator pattern, constructor injection, MEF and Autofac, and Autofac 2's new features.
Registering open generic types in Autofac 1.4
Published:5 min readThis post explains how to extend Autofac 1.4 to register open generic types, with support for both interfaces and classes. It provides an example unit test and the code used to implement the extension method.
Registering open generic interface types in Autofac
Published:8 min readThis post covers how to register open generic interface types in Autofac V2, using the new RegisterAssemblyTypes method and an extension method. Nicholas Blumhardt (the creator of Autofac) suggested that this would be easy to implement, and it was done with a few unit tests and implementation code.