CDCavell.ApplicationConfiguration 1.0.2

dotnet add package CDCavell.ApplicationConfiguration --version 1.0.2                
NuGet\Install-Package CDCavell.ApplicationConfiguration -Version 1.0.2                
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="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CDCavell.ApplicationConfiguration --version 1.0.2                
#r "nuget: CDCavell.ApplicationConfiguration, 1.0.2"                
#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=1.0.2

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

ApplicationConfiguration

ASP.NET 8.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 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 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. 
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
1.0.2 85 6/24/2024
1.0.1 89 6/23/2024