CDCavell.ApplicationConfiguration
1.0.3
See the version list below for details.
dotnet add package CDCavell.ApplicationConfiguration --version 1.0.3
NuGet\Install-Package CDCavell.ApplicationConfiguration -Version 1.0.3
<PackageReference Include="CDCavell.ApplicationConfiguration" Version="1.0.3" />
paket add CDCavell.ApplicationConfiguration --version 1.0.3
#r "nuget: CDCavell.ApplicationConfiguration, 1.0.3"
// Install CDCavell.ApplicationConfiguration as a Cake Addin #addin nuget:?package=CDCavell.ApplicationConfiguration&version=1.0.3 // Install CDCavell.ApplicationConfiguration as a Cake Tool #tool nuget:?package=CDCavell.ApplicationConfiguration&version=1.0.3
ApplicationConfiguration
ASP.NET 8.0 Service utilized to bind ApplicationConfiguration section of configuration environment into a custom class for dependency injection
<hr />
<hr />
ApplicationConfiguration is a .Net 8.0 Service utilized to bind ApplicationConfiguration section of configuration environment into a custom class for dependency injection.
Target Framework is ASP.NET Core 8.0. Developed and built in a Windows environment utilizing Visual Studio Community 2022 source-code editor.
This work is licensed under the MIT License. Assets are licensed under their respective licensing.
<hr />
To utilize, add following to Program.cs
where AppConfig
is custom class to bind
ApplicationConfiguration section to:
private static AppConfig? _applicationConfiguration;
...
var builder = WebApplication.CreateBuilder(args);
_applicationConfiguration = new(builder.Configuration);
builder.Services.AddApplicationConfigurationService(options =>
{
options.ApplicationConfiguration = _applicationConfiguration;
});
Example of custom class (requires IConfiguration passed into constructor):
public class AppConfig(IConfiguration configuration) : ApplicationConfiguration.Models.ApplicationConfiguration(configuration)
{
}
If configuration environment has sections under ApplicationConfiguration section, then each section is it's own class within custom class. Example:
public class AppConfig(IConfiguration configuration) : ApplicationConfiguration.Models.ApplicationConfiguration(configuration)
{
public ConnectionStrings ConnectionStrings { get; set; } = new();
}
public class ConnectionStrings
{
public string ApplicationDbConnection { get; set; } = string.Empty;
}
Custom class can now be utilized in dependency injection:
public abstract class ApplicationBaseController<T>(
ILogger<T> logger,
IApplicationConfigurationService applicationConfigurationService
) : WebBaseController<ApplicationBaseController<T>>(logger) where T : ApplicationBaseController<T>
{
protected readonly AppConfig _applicationConfiguration = applicationConfigurationService.ToObject<AppConfig>();
}
<hr />
Authenticate to GitHub Packages:
<br />Replace USERNAME
with your GitHub User Name
<br />Replace YOUR_GITHUB_PAT
with your personal access token
<br />Replace NAMESPACE
with the name of the personal account or organization to which your packages are scoped
> dotnet nuget add source --username USERNAME --password YOUR_GITHUB_PAT --store-password-in-clear-text --name github "https://nuget.pkg.github.com/NAMESPACE/index.json"
Publish Package:
<br />Replace PACKAGE
with your NuGet Package Name
<br />Replace YOUR_GITHUB_PAT
with your personal access token
> dotnet nuget push "bin/Release/PACKAGE.nupkg" --api-key YOUR_GITHUB_PAT --source "github"
<hr />
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.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.