-
Notifications
You must be signed in to change notification settings - Fork 6
Technicalities
Patrick Klaeren edited this page Dec 11, 2022
·
1 revision
AutoRegisterInject will source generate into two files. AutoRegisterInject.Attributes.g.cs
- containing the definitions of the three individual attributes, RegisterScoped
, RegisterSingleton
and RegisterTransient
.
Service registrations are generated into AutoRegisterInject.ServiceCollectionExtension.g.cs
.
Service collections will be generated into a static class where AutoRegister
is an internal
extension method to register the current project's dependencies and AutoRegisterFromAssemblyName
is a public
extension method that can be invoked from the same or external projects referencing this one. AutoRegisterFromAssemblyName
invokes AutoRegister
internally.
using Microsoft.Extensions.DependencyInjection;
public static class AutoRegisterInjectServiceCollectionExtension
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AutoRegisterFromAssemblyName(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection)
{
return AutoRegister(serviceCollection);
}
internal static Microsoft.Extensions.DependencyInjection.IServiceCollection AutoRegister(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection)
{
return serviceCollection;
}
}