https://github.com/salman-basmechi/reguto
Reguto is a tool for register dependencies and options automatically based on attributes.
https://github.com/salman-basmechi/reguto
c-sharp dependency-injection microsoft-dependency-injection options-configuration reguto
Last synced: about 1 month ago
JSON representation
Reguto is a tool for register dependencies and options automatically based on attributes.
- Host: GitHub
- URL: https://github.com/salman-basmechi/reguto
- Owner: salman-basmechi
- License: mit
- Created: 2020-11-26T18:34:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T09:04:08.000Z (about 4 years ago)
- Last Synced: 2025-03-28T05:05:25.883Z (about 2 months ago)
- Topics: c-sharp, dependency-injection, microsoft-dependency-injection, options-configuration, reguto
- Language: C#
- Homepage:
- Size: 53.7 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Reguto
=======
Scan and register all dependencies and options automatically based on attributes.You can get the latest stable release from the [nuget.org](http://www.nuget.org/packages/reguto) or from [github releases page](https://github.com/salmanbasmechi/reguto/releases).
```C#
public interface IIdentityService
{
Task AuthenticateAsync(string username, string password);
}
```Annotate service class as scoped dependency with ServiceAttribute
```C#
[Service]
public class IdentityService : IIdentityService
{
private readonly IOptions options;public IdentityService(IOptions options)
{
this.options = options ?? throw new ArgumentNullException(nameof(options));
}public Task AuthenticateAsync(string username, string password)
{
throw new NotImplementedException();
}
}
```Annotate options class and determine value section in appSettings.json or other settings file.
```C#
[Options("Jwt")]
public class JwtOptions
{
public string Secret { get; init; }public string ExpiryMinutes { get; init; }
}
```Register all dependencies and options in startup.
```C#
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Reguto.DI.Microsoft;
using Reguto.Options.Microsoft;namespace Web
{
public class Startup
{
public IConfiguration Configuration { get; }public void ConfigureServices(IServiceCollection services)
{
services.AddReguto();
services.ConfigureReguto(Configuration);
}public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// configure
}
}
}
```