Phema.Configuration 3.0.0-preview3.0.0

C# strongly typed IConfiguration wrapper

This is a prerelease version of Phema.Configuration.
There is a newer version of this package available.
See the version list below for details.
Install-Package Phema.Configuration -Version 3.0.0-preview3.0.0
dotnet add package Phema.Configuration --version 3.0.0-preview3.0.0
<PackageReference Include="Phema.Configuration" Version="3.0.0-preview3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Phema.Configuration --version 3.0.0-preview3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Phema.Configuration, 3.0.0-preview3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Phema.Configuration as a Cake Addin
#addin nuget:?package=Phema.Configuration&version=3.0.0-preview3.0.0&prerelease

// Install Phema.Configuration as a Cake Tool
#tool nuget:?package=Phema.Configuration&version=3.0.0-preview3.0.0&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Phema.Configuration

Nuget

C# strongly typed IConfiguration wrapper

Usage

[Configuration]
public class RootConfiguration
{
  public InnerConfiguration Inner { get; set; }
}

[Configuration]
public class InnerConfiguration
{
}

// Add
WebHost.CreateDefaultBuilder<Startup>()
  .UseConfiguration<RootConfiguration>()
  .Build();

// Get
var root = provider.GetRequiredService<IOptions<RootConfiguration>>().Value;

var inner = provider.GetRequiredService<IOptions<InnerConfiguration>>().Value;

Assert.Equal(root.Inner, inner);
  • Maps IConfiguration from Microsoft.Extensions.Configuration to strongly typed configuration
  • You can add configuration by calling UseConfiguration<T> on IWebHostBuilder
  • You need to mark all your configuration parts by ConfigurationAttribute in this package
  • You can add ConfigurationAttribute to class or property if class is not avaliable to modification
  • You can override property names using DataMember and DataContract attribute
  • All configuration parts adds to IServiceCollection recursively, so you can resolve them in app calling IServiceProvider or inject using DI

Phema.Configuration

Nuget

C# strongly typed IConfiguration wrapper

Usage

[Configuration]
public class RootConfiguration
{
  public InnerConfiguration Inner { get; set; }
}

[Configuration]
public class InnerConfiguration
{
}

// Add
WebHost.CreateDefaultBuilder<Startup>()
  .UseConfiguration<RootConfiguration>()
  .Build();

// Get
var root = provider.GetRequiredService<IOptions<RootConfiguration>>().Value;

var inner = provider.GetRequiredService<IOptions<InnerConfiguration>>().Value;

Assert.Equal(root.Inner, inner);
  • Maps IConfiguration from Microsoft.Extensions.Configuration to strongly typed configuration
  • You can add configuration by calling UseConfiguration<T> on IWebHostBuilder
  • You need to mark all your configuration parts by ConfigurationAttribute in this package
  • You can add ConfigurationAttribute to class or property if class is not avaliable to modification
  • You can override property names using DataMember and DataContract attribute
  • All configuration parts adds to IServiceCollection recursively, so you can resolve them in app calling IServiceProvider or inject using DI

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.0 191 9/8/2019
3.0.0-preview3.0.2 210 4/12/2019
3.0.0-preview3.0.1 174 4/11/2019
3.0.0-preview3.0.0 172 3/30/2019