liveBook · Manning

Implementation type

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

An implementation type is the concrete class that a dependency injection container creates to fulfill a service dependency.

An implementation type is the concrete class a dependency injection container creates when an application requests a service. For example, registering IEmailSender with EmailSender tells the container, “Use EmailSender when IEmailSender is required.” section 9.1

A service registration describes three related choices:

  • Service type: the class or interface requested as a dependency. section 9.1
  • Implementation type: the concrete class created to fulfill that request. section 9.1
  • Lifetime: how long the container reuses an instance, such as transient, scoped, or singleton. section 9.6

Mapping an interface to its implementation

builder.Services.AddScoped<IEmailSender, EmailSender>(); When an endpoint asks for IEmailSender, the container creates EmailSender and supplies its registered dependencies. The implementation type must be concrete; an interface or abstract class cannot be created directly. section 9.1

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

How deep it goes
Defines the mapping, concrete-type requirement, and registration forms, while deferring detailed lifetime behavior to separate treatment.
Examples
Uses IEmailSender with EmailSender, plus NetworkClient and MessageFactory registrations in an ASP.NET Core application.
What it assumes
Assumes basic classes, interfaces, and dependencies, while defining concrete types and showing registration syntax.
What you can do after
Configure dependency injection mappings that let endpoints request abstractions while the container creates registered concrete implementations.
How it connects
Connects service type, dependency injection, constructor injection, service lifetime, and concrete types.

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.