aemarcoToolboxAppOptions 3.1.6
See the version list below for details.
dotnet add package aemarcoToolboxAppOptions --version 3.1.6
NuGet\Install-Package aemarcoToolboxAppOptions -Version 3.1.6
<PackageReference Include="aemarcoToolboxAppOptions" Version="3.1.6" />
paket add aemarcoToolboxAppOptions --version 3.1.6
#r "nuget: aemarcoToolboxAppOptions, 3.1.6"
// Install aemarcoToolboxAppOptions as a Cake Addin #addin nuget:?package=aemarcoToolboxAppOptions&version=3.1.6 // Install aemarcoToolboxAppOptions as a Cake Tool #tool nuget:?package=aemarcoToolboxAppOptions&version=3.1.6
aemarcoToolboxAppOptions
<a href=https://www.nuget.org/packages/aemarcoToolboxAppOptions><img src="https://buildstats.info/nuget/aemarcoToolboxAppOptions"></a><br/>
Overview
This package provides a opinionated approach to the Options pattern described in the Microsoft docs. With minimal setup, all the Option classes will be registered in the IOC container and mapped to the IConfiguration source.
- Automatic mapping of sections to classes (convention driven, but can be adjusted)
- Beside registering the interfaces from Microsoft, registers the class itself as well (singleton)
- Registers also interfaces which you put on the settings class
- Allows text transformations between IConfiguration and the settings class
- Option to use fluent validation on settings
- Option to validate settings during startup (on by default, opt-out in options)
Get Started
During startup of the app
{
services.AddConfigOptionsUtils(config);
}
Create your class representing your options
{
public class MySettings : ISettingsBase
{
public string? Text { get; set; }
public bool Enable { get; set; }
}
}
In appsetting.json (or other IConfiguration source)
{
"MySettings": {
"Text": "SomeText",
"Enable": true
}
}
StringTransformation
String transformations will be executed in the order defined in the setup process. You could define your own, but PlaceholderTransformation is built in already.
{
services.AddConfigOptionsUtils(
config,
x => x
.AddStringTransformation(new PlaceholderTransformation());
}
PlaceholderTransformation does resolve placeholders {{{...}}} through the entire IConfguration by Key. That maybe usefull when piecing together file or url path.
{
"Message": "Hello world!",
"MySettings": {
"Text": "The message is {{{Message}}}",
"Enable": true
}
}
Fluent Validation
Just define your Validators in the assemblies where setting classes are defined. The tool will register them, and use them if present. By default, Validation takes place at startup.
{
services.AddConfigOptionsUtils(
config,
x => x
.EnableValidationOnStartup(false); //on by default
}
Setting classes in multiple assemblies
The tool relies on assembly scanning during the setup. If your option classes are in other assemblies, you may pass one of the types as assembly marker, and/or use the assemblies itself.
{
services.AddConfigOptionsUtils(
config,
x => x
.AddAssemblyMarker(typeof(MySettings))
// and/or
.AddAssemblies(someAssemblies));
}
Mapping Path
By default, the class name is exactly matched to the root level of the configuration. You may define your own path in the settings class
{
[SettingsPath("Settings")]
public class MySettings : ISettingsBase
{
public string? Text { get; set; }
public bool Enable { get; set; }
}
}
would map to
{
"Settings": {
"Text": "SomeText",
"Enable": true
}
}
You could even do it nested, just use the colon seperated path as you would with GetSection().
{
[SettingsPath("Settings:Nested")]
public class MySettings : ISettingsBase
{
public string? Text { get; set; }
public bool Enable { get; set; }
}
}
would map to
{
"Settings": {
"Nested":{
"Text": "SomeText",
"Enable": true
}
}
}
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. |
-
net8.0
- aemarcoExtensions (>= 3.1.6)
- FluentValidation.DependencyInjectionExtensions (>= 11.8.1)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on aemarcoToolboxAppOptions:
Package | Downloads |
---|---|
aemarcoWpfTools
c# wpf tools collection |
|
aemarcoWebTools
c# web tools collection |
|
aemarcoConsoleTools
c# console tools collection |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.4 | 64 | 11/17/2024 |
8.0.3 | 71 | 11/17/2024 |
5.0.21 | 74 | 11/16/2024 |
5.0.20 | 98 | 10/20/2024 |
5.0.19 | 87 | 10/19/2024 |
5.0.18 | 114 | 10/19/2024 |
5.0.17 | 98 | 10/13/2024 |
5.0.16 | 87 | 10/12/2024 |
5.0.6 | 79 | 10/6/2024 |
5.0.5 | 88 | 10/2/2024 |
5.0.4 | 77 | 10/1/2024 |
5.0.3 | 82 | 9/22/2024 |
5.0.2 | 177 | 9/16/2024 |
4.0.9 | 99 | 9/15/2024 |
4.0.8 | 93 | 9/8/2024 |
4.0.7 | 75 | 9/8/2024 |
4.0.6 | 82 | 9/8/2024 |
4.0.5 | 73 | 9/8/2024 |
4.0.2 | 104 | 9/8/2024 |
3.1.27 | 96 | 9/8/2024 |
3.1.26 | 100 | 9/7/2024 |
3.1.25 | 98 | 9/7/2024 |
3.1.24 | 95 | 9/7/2024 |
3.1.23 | 85 | 9/1/2024 |
3.1.22 | 91 | 9/1/2024 |
3.1.21 | 113 | 6/16/2024 |
3.1.20 | 93 | 5/31/2024 |
3.1.19 | 85 | 5/20/2024 |
3.1.18 | 93 | 5/10/2024 |
3.1.17 | 117 | 4/12/2024 |
3.1.16 | 115 | 4/4/2024 |
3.1.15 | 133 | 3/22/2024 |
3.1.11 | 118 | 3/19/2024 |
3.1.10 | 124 | 2/16/2024 |
3.1.7 | 142 | 2/11/2024 |
3.1.6 | 127 | 2/11/2024 |
3.1.5 | 119 | 2/11/2024 |
3.1.4 | 113 | 2/11/2024 |
3.0.18 | 174 | 1/29/2024 |
3.0.17 | 104 | 1/29/2024 |
3.0.16 | 103 | 1/27/2024 |
3.0.15 | 103 | 1/27/2024 |
3.0.8 | 106 | 1/27/2024 |
3.0.7 | 163 | 1/13/2024 |
2.0.18 | 180 | 1/4/2024 |
2.0.17 | 191 | 1/1/2024 |
2.0.16 | 186 | 12/27/2023 |
2.0.15 | 175 | 12/26/2023 |
2.0.14 | 182 | 12/26/2023 |
2.0.13 | 156 | 12/25/2023 |
2.0.11 | 147 | 12/23/2023 |
2.0.10 | 179 | 12/16/2023 |
2.0.9 | 164 | 12/15/2023 |
2.0.8 | 183 | 12/14/2023 |
2.0.7 | 174 | 12/13/2023 |
2.0.5 | 193 | 12/11/2023 |
2.0.4 | 180 | 12/11/2023 |
2.0.2 | 201 | 12/10/2023 |
1.9.2 | 184 | 12/10/2023 |
1.8.4 | 197 | 12/10/2023 |
1.8.3 | 217 | 12/9/2023 |
1.8.2 | 186 | 12/9/2023 |
1.1.28 | 225 | 11/27/2023 |
1.1.27 | 190 | 11/26/2023 |
1.1.26 | 211 | 11/18/2023 |
1.1.25 | 191 | 11/17/2023 |
1.1.24 | 245 | 10/30/2023 |
1.1.23 | 206 | 10/29/2023 |
1.1.22 | 214 | 10/22/2023 |
1.1.21 | 226 | 10/17/2023 |
1.1.20 | 246 | 9/16/2023 |
1.1.19 | 313 | 8/27/2023 |
1.1.18 | 237 | 7/31/2023 |
1.1.17 | 267 | 7/16/2023 |
1.1.16 | 260 | 7/9/2023 |
1.1.15 | 280 | 7/8/2023 |
1.1.14 | 278 | 7/5/2023 |
1.1.13 | 252 | 6/29/2023 |
1.1.12 | 265 | 5/1/2023 |
1.1.11 | 433 | 3/5/2023 |
1.1.10 | 391 | 3/3/2023 |
1.1.9 | 418 | 2/28/2023 |
1.1.7 | 444 | 2/26/2023 |
1.1.6 | 407 | 2/26/2023 |
1.1.5 | 284 | 2/26/2023 |
1.1.3 | 268 | 2/25/2023 |