Skip to content

Register services according to container with service lifetime attributes

License

Notifications You must be signed in to change notification settings

javlonfattoev/JFA.DependencyInjection

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages