Skip to content

Frederik91/DependencyInjection.SourceGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DependencyInjection.SourceGenerator

Register services using attributes instead of registering in code.

Usage

Add the "Register" attribute to the class you want to register. The attribute takes a type and a lifetime. The type is the type you want to register and the lifetime is the lifetime of the service. The lifetime is optional and defaults to Transient.

This library supports the following dependency injection frameworks, follow the links for more information on how to use them:

To use this library you need to install the source generator package and the contacts package. The source generator package is a development dependency and will not be exposed as a dependency to consumers of your projects, while the contracts package contains the attributes and enums used to configure the generator.

Microsoft.Extensions.DependencyInjection

  • DependencyInjection.SourceGenerator.Microsoft NuGet

  • DependencyInjection.SourceGenerator.Microsoft.Contracts NuGet

LightInject

  • DependencyInjection.SourceGenerator.LightInject NuGet

  • DependencyInjection.SourceGenerator.LightInject.Contracts NuGet

Both contracts packages references the shared contracts package, which contains the attributes and enums used to configure the generator.

  • DependencyInjection.SourceGenerator.Contracts NuGet

Lifetime

The lifetime is an enum with the following values:

  • Transient
  • Scoped
  • Singleton

About

Register services using attributes instead of registering.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages