register-and-replace-services

Installation
SKILL.md

Registering and Replacing Services

ABP builds on IServiceCollection: conventional registrars choose a lifetime and exposed service types, while attributes and registration callbacks let a module change those choices. Use constructor injection for normal dependencies; use the advanced mechanisms here only when exposure, replacement, late resolution, keys, activation hooks, or decoration requires them.

When to Use

  • Restrict or expand which service types a conventionally registered class exposes.
  • Replace an existing interface/base-class registration without editing the original module.
  • Observe or modify service exposure and registration during assembly scanning.
  • Resolve optional services lazily or pass an object into startup/runtime code through IObjectAccessor<T>.
  • Register several implementations under keys, including string keys used as names.
  • Wrap an existing implementation while preserving its registered lifetime.

When Not to Use

  • Create a module or learn its lifecycle/basic DI markers — use define-application-modules.
  • Attach method interceptors — use use-interceptors-and-dynamic-proxy.
  • Customize a packaged module across entity, DTO, service, and UI extension points — use customize-application-modules.
Installs
26
GitHub Stars
32
First Seen
Aug 15, 2026