Albatross.Config
7.5.6
Prefix Reserved
See the version list below for details.
dotnet add package Albatross.Config --version 7.5.6
NuGet\Install-Package Albatross.Config -Version 7.5.6
<PackageReference Include="Albatross.Config" Version="7.5.6" />
paket add Albatross.Config --version 7.5.6
#r "nuget: Albatross.Config, 7.5.6"
// Install Albatross.Config as a Cake Addin #addin nuget:?package=Albatross.Config&version=7.5.6 // Install Albatross.Config as a Cake Tool #tool nuget:?package=Albatross.Config&version=7.5.6
Albatross.Config
Simplified configuration setup for your .Net applications.
Features
- Use Strong typed configuration class without using the IOptions<> interface.
- Built-In ProgramSetting and EnvironmentSetting config class.
- Built-In endpoints configuration key similar to the connectionStrings key provided by default.
- Validate configuration data using data annotation attributes in the System.DataAnnotation namespace or implement your own validation.
- Custom implementation of IHostEnvironment to save us from changing prod data by accident. See HELP! My developers are also DBAs.
Related Articles
- The Comparison between Albatross.Config and the default IOptions<> Setup
- .Net Hosting Environments
- Use of Environment Variables and Command Line Parameters
Quick Start
Albatross.Config
allows users to create strong typed config classes to manage the configuration data. The config class requires a base class of Albatross.Config.ConfigBase
and a constructor with a single parameter of type Microsoft.Extensions.Configuration.IConfiguration
.
Here is an example of appsettings.json file and the matching config class.
{
"connectionStrings" : {
"azure-db" : "..."
},
"endpoints": {
"ms-graph" : "..."
},
"my-config" : {
"configData" : "..."
}
}
public class MyConfig : ConfigBase {
public MyConfig(IConfiguration configuration) {
this.MsGraphicEndPoint = configuration.GetRequiredEndPoint("ms-graph");
this.MyConnectionString = configuration.GetRequiredConnectionString("azure-db");
}
public override Key => "my-config";
[Required]
public string ConfigData { get; }
public string MsGraphicEndPoint { get; }
public string MyConnectionString { get; }
public override void Validate() {
base.Validate();
}
}
If the Key of the config class is defined, the json values of the key in the appsettings.json
file will be binded to the config class. The Validate
method of the class will be invoked after the creation of its instance. An exception will be thrown if there are any validation errors.
Once the config class is registered using DI, it can be injected directly to classes as a dependency. The AddConfig
method by default registers the config class as a Singleton. AddConfig(false)
will register the class with a scoped lifetime. The scoped lifetime is useful in the rare case of config data change.
public static IServiceCollection RegisterMyServices(this IServiceCollection services) {
services.AddConfig<MyConfig>();
return services;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 8.0.0)
- Microsoft.Extensions.Configuration.FileExtensions (>= 8.0.1)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Albatross.Config:
Package | Downloads |
---|---|
Albatross.Hosting
A library for creating .Net Web Api or Service applications with preconfigured settings |
|
Albatross.Caching
This assembly contains cache management logic using Polly |
|
Albatross.Hosting.Utility
Wrapper api to create a command line utility using CommandLineParser with dependency injection and serilog logging support. |
|
Albatross.Hosting.Test
hosting framework for test projects |
|
Albatross.Messaging
This assembly contains messaging implementation using ZeroMQ. Currently it supports pubsub and command queue pattern. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.5.8 | 29 | 11/19/2024 |
7.5.7 | 47 | 11/11/2024 |
7.5.6 | 36 | 11/8/2024 |
7.5.5 | 35 | 11/7/2024 |
7.5.4 | 25 | 11/7/2024 |
7.4.2 | 69 | 10/8/2024 |
7.4.1 | 64 | 10/5/2024 |
6.1.1 | 463 | 9/18/2023 |
4.0.2 | 1,108 | 10/18/2022 |
2.8.0 | 921 | 8/11/2021 |
2.3.6 | 817 | 2/23/2021 |
1.6.8 | 1,016 | 1/8/2021 |
1.6.7 | 3,579 | 9/24/2020 |
1.6.6 | 2,041 | 8/21/2020 |
1.6.2 | 877 | 8/5/2020 |
1.6.1 | 673 | 7/30/2020 |
1.6.0 | 1,618 | 7/27/2020 |
1.5.33 | 1,490 | 7/9/2020 |