Blog Posts for: Dependency Injection

Dependency injection with Autofac and Azure WebJobs

25 August 2015

Introduction At the end of last year I wrote a blog post that demonstrated how you could use Autofac and the Common Service Locator in Azure WebJobs to resolve dependencies. At that time there was no way to inject dependencies, as Azure WebJobs functions had to be static methods and therefore there was no object instance into which dependencies could be injected. The Service Locator pattern worked fine for that scenario, but it was not necessarily an ideal situation.

Resolve dependencies differently depending on whether user is logged in

18 August 2015

In a recent project I had to collect information from a user, and store that information so that we have the information available during the entire browsing session. The application allowed for users to use the application anonymously, in which case I would store the information in a session variable. If a user was however logged into the application, I would store the information inside a database table so that it would be available on the next visit.

Using Fluent Validation with ASP.NET MVC - Part 3: Adding Dependency Injection

26 May 2013

In the previous blog post we looked at how to do unit testing with FluentValidation. My goal is to show you how we can write validators which can validate information in the database, but still be easy to unit test. For this we will make use of dependency injection, mocking and the repository pattern. Before we can write and unit test the actual database validator we need to put dependency injection in place as it will make things a bit easier for us going ahead.