ToolBX.AutoConfig
2.2.0
dotnet add package ToolBX.AutoConfig --version 2.2.0
NuGet\Install-Package ToolBX.AutoConfig -Version 2.2.0
<PackageReference Include="ToolBX.AutoConfig" Version="2.2.0" />
paket add ToolBX.AutoConfig --version 2.2.0
#r "nuget: ToolBX.AutoConfig, 2.2.0"
// Install ToolBX.AutoConfig as a Cake Addin
#addin nuget:?package=ToolBX.AutoConfig&version=2.2.0
// Install ToolBX.AutoConfig as a Cake Tool
#tool nuget:?package=ToolBX.AutoConfig&version=2.2.0
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 | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- Microsoft.Extensions.Configuration.Binder (>= 8.0.1)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.1)
- ToolBX.Reflection4Humans.TypeFetcher (>= 2.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ToolBX.AutoConfig:
Package | Downloads |
---|---|
ToolBX.AssemblyInitializer
Helps decouple initialization logic by splitting it into AssemblyInitializer classes. |
|
ToolBX.FileGuy
High-level API for handling files. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.0 | 607 | 1/11/2024 |
2.2.0-beta3 | 154 | 1/7/2024 |
2.2.0-beta1 | 132 | 7/26/2023 |