kdheath.Configuration.Helper 1.0.3-alpha1

This is a prerelease version of kdheath.Configuration.Helper.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package kdheath.Configuration.Helper --version 1.0.3-alpha1
                    
NuGet\Install-Package kdheath.Configuration.Helper -Version 1.0.3-alpha1
                    
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="kdheath.Configuration.Helper" Version="1.0.3-alpha1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="kdheath.Configuration.Helper" Version="1.0.3-alpha1" />
                    
Directory.Packages.props
<PackageReference Include="kdheath.Configuration.Helper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add kdheath.Configuration.Helper --version 1.0.3-alpha1
                    
#r "nuget: kdheath.Configuration.Helper, 1.0.3-alpha1"
                    
#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.
#:package kdheath.Configuration.Helper@1.0.3-alpha1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=kdheath.Configuration.Helper&version=1.0.3-alpha1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=kdheath.Configuration.Helper&version=1.0.3-alpha1&prerelease
                    
Install as a Cake Tool

About

The Configuration.Helper package is a light-weight platform for .NET to support application settings in old-style App.config files, and as of version 1.0.1, the newer style of JSON files.

How to Use

  • The naming of the standard sections AppSettings and ConnectionStrings along with any custom sections are case insensitive.
  • All the values must be defined as strings.

A JSON style configuration file would look like:

{
  "appSettings": {
    "FavoriteMovie": "Dune",
    "FavoriteDirector": "James Cameron",
    "FavoriteActor": "Johnny Depp"
  },
  "connectionStrings": {
    "Movies": "DataSource=localhost;Initial Catalog=MovieCatalog;Integrated Security=True"
  },
  "Custom": {
    "Password": "abc123"
  }
}


The older style XML application settings file would look like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="FavouriteMovie" value="Dune" />
    <add key="FavouriteDirector" value="James Cameron" />
    <add key="FavouriteActor" value="Johnny Depp" />
   </appSettings>

  <connectionStrings>
    <clear />
    <add name="Movies" connectionString="DataSource=localhost;Initial Catalog=MovieCatalog;Integrated Security=True" />
  </connectionStrings>

  <Custom>
    <add key="Password" value="abc123" />
  </Custom>
</configuration>


To access the settings from C# code:

using Configuration.Helper;

// Load the configuration settings
var config = ConfigFileHelper.GetConfiguration( "appSettings.json" );

// Get a setting value from the AppSettings section
var director = config.GetSetting( "favoritedirector" );

// Get a setting value from the ConnectionStrings section
var connect = config.ConnectionStrings.GetSetting( "movies" );

// Get a setting value from the Custom section
var password = config.GetSection( "custom" ).GetSetting( "password" );

// Add or update a setting value in the AppSettings section
var ok = config.AddSetting( "FavouriteActress", "Julia Roberts" );
ok = config.AddSetting( @"favouriteactress", "Angelina Jolie" );

Main Types

  • ConfigFileHelper - Helper class for Configuration file access.
  • IOHelper - Helper class for System.IO operations.
  • WebConnectionStringBuilder - Provides a simple way to create and manage the contents of connection strings used for a Microsoft Dataverse connection.

Feedback

This is provided as open source under the MIT license.
Bug reports and contributions are welcome at the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated

* Added support for .NET 8.0
* Updated project website and source repository links.