kdheath.Configuration.Helper 1.0.3

Prefix Reserved
Additional Details

The source repository no longer exists.

There is a newer version of this package available.
See the version list below for details.
dotnet add package kdheath.Configuration.Helper --version 1.0.3                
NuGet\Install-Package kdheath.Configuration.Helper -Version 1.0.3                
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" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add kdheath.Configuration.Helper --version 1.0.3                
#r "nuget: kdheath.Configuration.Helper, 1.0.3"                
#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 kdheath.Configuration.Helper as a Cake Addin
#addin nuget:?package=kdheath.Configuration.Helper&version=1.0.3

// Install kdheath.Configuration.Helper as a Cake Tool
#tool nuget:?package=kdheath.Configuration.Helper&version=1.0.3                

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

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.5 107 5/1/2024
2.0.4 156 4/1/2024
2.0.3 226 3/3/2024
2.0.2 261 2/17/2024
2.0.1 509 12/8/2023
2.0.0 420 11/30/2023
1.0.3 417 11/21/2023 1.0.3 is deprecated.
1.0.2 449 11/11/2023 1.0.2 is deprecated.

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