Skip to content

Repository files navigation

JFA.DependencyInjection

Register services according to container with service lifetime attributes

Install package from nuget.org

NuGet\Install-Package JFA.DependencyInjection -Version <VERSION>

Add lifetime attribute to service implementations

[Scoped]
public class UsersService : IUsersService
{...}

[Transient]
public class ProductsService : IProductsService
{...}

[Singleton]
public class OrdersService : IOrdersService
{...}

Add following line to Program.cs file

builder.Services.AddServicesFromAttribute();

Now you can inject services

public UsersController(IUsersService usersService)
{...}

About

Register services according to container with service lifetime attributes

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages