https://github.com/maxchistt/injectableservices
NuGet package for creating injectable services for DependencyInjection
https://github.com/maxchistt/injectableservices
dependency-injection injectable injectable-service injection services
Last synced: about 1 year ago
JSON representation
NuGet package for creating injectable services for DependencyInjection
- Host: GitHub
- URL: https://github.com/maxchistt/injectableservices
- Owner: maxchistt
- License: mit
- Created: 2023-11-16T07:43:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-16T08:43:38.000Z (over 2 years ago)
- Last Synced: 2025-05-24T23:43:14.654Z (about 1 year ago)
- Topics: dependency-injection, injectable, injectable-service, injection, services
- Language: C#
- Homepage: https://nuget.org/packages/InjectableServices
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# InjectableServices
1. Add `Injectable` attribute to your service
```cs
using InjectableServices;
// The attribute
[Injectable(ServiceLifetime.Scoped)]
public class ItemService : IItemService
{
private DataContext Context { get; }
public ItemService(DataContext dataContext)
{
Context = dataContext;
}
public Item[] GetAllItems()
{
return Context.Items.ToArray();
}
}
```
1. Easily register injectable services
```cs
using InjectableServices;
var builder = WebApplication.CreateBuilder(args);
// The services registration
builder.Services.AddInjectableServices();
var app = builder.Build();
```