CodingCat.Extensions.Configuration 0.1.0

dotnet add package CodingCat.Extensions.Configuration --version 0.1.0
NuGet\Install-Package CodingCat.Extensions.Configuration -Version 0.1.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="CodingCat.Extensions.Configuration" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodingCat.Extensions.Configuration --version 0.1.0
#r "nuget: CodingCat.Extensions.Configuration, 0.1.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 CodingCat.Extensions.Configuration as a Cake Addin
#addin nuget:?package=CodingCat.Extensions.Configuration&version=0.1.0

// Install CodingCat.Extensions.Configuration as a Cake Tool
#tool nuget:?package=CodingCat.Extensions.Configuration&version=0.1.0

CodingCat.Extensions.Configuration

Provides extensions to configure dotnet configurations easier.

Provide the configurations folder path

The original dotnet IConfigurationBuilder provided a function to set the base path, however in some cases we are too lazy and hoping just use the relative path.

With this library, it provides an extension function SetRelativePath which uses the AppDomain.CurrentDomain.BaseDirectory internally.

var builder = new ConfigurationBuilder()
  .SetRelativePath("App_Data/Configurations");
Register your configurations

In a larger scale system, we would always love to group the same purpose of configurations by classes. This library provides some extension functions to do so in an easier way:

var systemConfigurationSource = new ConfigurationSource<SystemConfiguration>(
  Environment.Default,
  FileType.Json,
  isOptional: false
);

var configurations = new ConfigurationBuilder()
  .Register(systemConfigurationSource)
  .Register(systemConfigurationSource
    .With(Environment.Develop)
    .With(isOptional: true)
  )
  .Build();
  
var systemConfiguration = configurations.Bind<SystemConfiguration>();
Auto registration

If the amount of configuration classes are too large to register the sources one by one, this library also provides the auto registration feature by setting the default environment file is required, but the others are optional:

var configurations = new ConfigurationBuilder()
  .Auto<SystemConfiguration>(FileType.Json) // -- Auto register SystemConfiguration.json, SystemConfiguration.Develop.json, SystemConfiguration.Staging.json, SystemConfiguration.Production.json
  .Auto<CacheConfiguration>(FileType.Json)
  .Auto<PricingConfiguration>(FileType.Json)
  .Auto<CheckoutConfiguration>(FileType.Json)
  .Build();
What if using DI?

Dotnet nowadays handles the operations by DI heavily and this library would also love to save you from some typing:

var services = new ServiceCollection()
  .AddOptions()
  .AutoConfigure<SystemConfiguration>(configurations)
  .AutoConfigure<CacheConfiguration>(configurations)
  .AutoConfigure<PricingConfiguration>(configurations)
  .AutoConfigure<CheckoutConfiguration>(configurations)
  .BuildServiceProvider();
var systemConfiguration = services.GetRequiredService<IOptionsSnapshot<SystemConfiguration>>();
Target Frameworks
  • .Net 4.6.1
  • .Net Standard 2.0
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.1.0 631 2/9/2020