Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection
open sourceMITfree
Scrutor is an open source .NET library by Kristian Hellang that adds assembly scanning and decoration to Microsoft.Extensions.DependencyInjection, the dependency injection container built into .NET. Its Scan method registers every class in an assembly that matches a filter, as its interfaces or a chosen type and with a chosen lifetime, including open generics. Its Decorate method wraps services that are already registered.
Problems it solves
- register all my services automatically by scanning assemblies in ASP.NET Core
- add a decorator to a service registered with Microsoft.Extensions.DependencyInjection
- avoid writing one AddTransient line per class in a .NET app
Features
- Scan: register every matching class in an assembly with a fluent API
- register as implemented interfaces, a single interface or the class itself
- transient, scoped or singleton lifetimes
- open generic interfaces, including several type parameters
- Decorate: wrap already registered services with decorators
Alternatives
The same job
These do what Scrutor does.
- Autofac An addictive Inversion of Control container for .NET
