Services lifetime scope with Autofac

Basically when we resolve a component with Autofac, we could register the object instance in the root container; this is not the best practice, because these components will never be disposed as long as the container lives, that normally is the lifetime of the application. Then, the root container will hold the references until the application … Continue reading Services lifetime scope with Autofac

Repository pattern with Autofac

The repository pattern is one of the most popular patterns used in the applications architecture. With Autofac we are able to manage the dependencies and the lifecycle of the repositories in our application. So let's starting with the implementation of a basic respository example, then we proceed with the Autofac configurations and with the test … Continue reading Repository pattern with Autofac

Register a singleton service with Autofac

Autofac is a popular and very useful IoC container, a tool that help us to manage the dependency injection in our application. What we want from a IoC container is the ability to instantiate the objects needed in different contexts and situations and define configurations, without worry about who and when instantiate these objects. Of … Continue reading Register a singleton service with Autofac