liveBook · Manning

Lamar

As explained in ASP.NET Core in Action, 3e

Lamar is an open-source .NET dependency injection and inversion-of-control container.

Lamar is an open-source .NET dependency-injection and inversion-of-control container. It replaces ASP.NET Core’s built-in container when simple service registration becomes limiting, while preserving the framework’s service-registration model. section 31.0 section 31.3

Install Lamar.Microsoft.DependencyInjection, call UseLamar on the application host, and register framework services through Lamar’s ServiceRegistry. AddControllersAsServices ensures Lamar builds API controllers.

Lamar adds capabilities that are useful as an application grows:

  • Assembly scanning registers services by convention. section 31.3
  • Automatic concrete-class registration reduces explicit registrations. section 31.3
  • Property injection, constructor selection, Lazy<T>, and Func<T> resolution extend container behavior. section 31.3
  • Debugging and testing tools help inspect the container. section 31.3

How ASP.NET Core in Action, 3e covers it

How deep it goes
Describes package setup, host integration, registration, and major features without detailing container internals.
Examples
Uses Lamar.Microsoft.DependencyInjection, UseLamar, AddControllersAsServices, and Scan with default conventions.
What it assumes
Assumes an ASP.NET Core application and a reason to extend basic dependency-injection registration.
What you can do after
Operate/configure it by installing Lamar, replacing the host container, registering framework services, and scanning assemblies by convention.
How it connects
Connects dependency injection with ASP.NET Core service registration, assembly scanning, property injection, and automatic registration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.