CDCavell.ApplicationConfiguration 2.0.0

dotnet add package CDCavell.ApplicationConfiguration --version 2.0.0                
NuGet\Install-Package CDCavell.ApplicationConfiguration -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CDCavell.ApplicationConfiguration" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CDCavell.ApplicationConfiguration --version 2.0.0                
#r "nuget: CDCavell.ApplicationConfiguration, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CDCavell.ApplicationConfiguration as a Cake Addin
#addin nuget:?package=CDCavell.ApplicationConfiguration&version=2.0.0

// Install CDCavell.ApplicationConfiguration as a Cake Tool
#tool nuget:?package=CDCavell.ApplicationConfiguration&version=2.0.0                

ApplicationConfiguration

ASP.NET 9.0 Service utilized to bind ApplicationConfiguration section of configuration environment into a custom class for dependency injection

<hr />

GitHub license GitHub top language GitHub language count

<hr />

ApplicationConfiguration is a .Net 9.0 Service utilized to bind ApplicationConfiguration section of configuration environment into a custom class for dependency injection.

Target Framework is ASP.NET Core 9.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 Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 75 11/16/2024
1.0.3 122 10/19/2024
1.0.2 109 6/24/2024
1.0.1 112 6/23/2024