CDCavell.ApplicationConfiguration 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package CDCavell.ApplicationConfiguration --version 1.0.1                
NuGet\Install-Package CDCavell.ApplicationConfiguration -Version 1.0.1                
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.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CDCavell.ApplicationConfiguration --version 1.0.1                
#r "nuget: CDCavell.ApplicationConfiguration, 1.0.1"                
#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.1

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

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);

    _appSettings = new(builder.Configuration);
    builder.Services.AddAppSettingsService(options =>
    {
        options.AppSettings = _appSettings;
    });

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 />

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.  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. 
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 95 11/16/2024
1.0.3 133 10/19/2024
1.0.2 119 6/24/2024
1.0.1 122 6/23/2024