ToolBX.AutoConfig
3.0.0-beta1
See the version list below for details.
dotnet add package ToolBX.AutoConfig --version 3.0.0-beta1
NuGet\Install-Package ToolBX.AutoConfig -Version 3.0.0-beta1
<PackageReference Include="ToolBX.AutoConfig" Version="3.0.0-beta1" />
paket add ToolBX.AutoConfig --version 3.0.0-beta1
#r "nuget: ToolBX.AutoConfig, 3.0.0-beta1"
// Install ToolBX.AutoConfig as a Cake Addin #addin nuget:?package=ToolBX.AutoConfig&version=3.0.0-beta1&prerelease // Install ToolBX.AutoConfig as a Cake Tool #tool nuget:?package=ToolBX.AutoConfig&version=3.0.0-beta1&prerelease
AutoConfig
A .NET library to make it easier to use appsettings sections using AutoConfig attributes directly on classes.
How does it work?
You write a configuration type, as you normally would except that you add a [AutoCondig]
attribute with a string
on top of it.
[AutoConfig("MyConfig")]
public sealed record Configuration
{
public string Name { get; init; }
public bool IsAwesome { get; init; }
}
The string
is the section name inside your appsettings.json
file.
{
"MyConfig": {
"name": "Roger",
"isAwesome": true
}
}
Getting started
In order for your configuration to be injected as an IOptions<T>
, you need to call the following method where you configure your application services :
services.AddAutoConfig(configuration);
Alternatively, you can also specify which assembly to use :
services.AddAutoConfig(Assembly.GetExecutingAssembly(), configuration);
The latter is more performant because the former will look through all your assemblies looking for anything with the [AutoConfig]
attribute on it. It is more convenient but it comes at certain a cost. Use the Assembly
overload if performance is a concern.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- ToolBX.Reflection4Humans.TypeFetcher (>= 3.0.0-beta5)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ToolBX.AutoConfig:
Package | Downloads |
---|---|
ToolBX.AssemblyInitializer
Helps decouple initialization logic by splitting it into AssemblyInitializer classes. |
|
ToolBX.MisterTerminal
A high level library to easily and cleanly build smarter console applications. |
|
ToolBX.FileGuy
High-level API for handling files. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 1,334 | 9/26/2024 |
3.0.0-beta1 | 176 | 9/23/2024 |
2.2.0 | 1,080 | 1/11/2024 |
2.2.0-beta3 | 271 | 1/7/2024 |
2.2.0-beta1 | 205 | 7/26/2023 |