Kralizek.Extensions.Configuration.Objects 4.0.0

dotnet add package Kralizek.Extensions.Configuration.Objects --version 4.0.0
                    
NuGet\Install-Package Kralizek.Extensions.Configuration.Objects -Version 4.0.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="Kralizek.Extensions.Configuration.Objects" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kralizek.Extensions.Configuration.Objects" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Kralizek.Extensions.Configuration.Objects" />
                    
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 Kralizek.Extensions.Configuration.Objects --version 4.0.0
                    
#r "nuget: Kralizek.Extensions.Configuration.Objects, 4.0.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.
#:package Kralizek.Extensions.Configuration.Objects@4.0.0
                    
#: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=Kralizek.Extensions.Configuration.Objects&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Kralizek.Extensions.Configuration.Objects&version=4.0.0
                    
Install as a Cake Tool

Kralizek.Extensions.Configuration.Objects

Add strongly typed objects directly to a Microsoft.Extensions.Configuration pipeline.

The library supports object graphs containing scalar values, nested objects, collections, and dictionaries.

Install

dotnet add package Kralizek.Extensions.Configuration.Objects

Add an object

builder.Configuration.AddObject(new
{
    FeatureEnabled = true,
    RetryCount = 3
});

AddObject appends the object configuration source, so it has higher precedence than configuration providers already registered.

Root section name

You can place the object under a root section:

builder.Configuration.AddObject(settings, "MySettings");

The root section can also be a configuration path:

builder.Configuration.AddObject(settings, "Features:Payments");

This makes the object available under Features:Payments.

Add fallback defaults

Use AddObjectAsFallback when the object should provide defaults that the rest of the configuration pipeline can override:

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddObjectAsFallback(new
{
    FeatureEnabled = false,
    RetryCount = 3
});

The fallback source is inserted at the lowest precedence, even when other providers are already registered. Values from appsettings.json, environment variables, command-line arguments, and other higher-precedence providers can override the defaults.

Source-generated System.Text.Json

Both APIs have overloads accepting JsonTypeInfo<T>. Use them with System.Text.Json source generation when reflection-based serialization is not appropriate, including trimming and Native AOT scenarios.

[JsonSerializable(typeof(MySettings))]
internal partial class AppJsonContext : JsonSerializerContext;

builder.Configuration.AddObject(
    new MySettings { FeatureEnabled = true },
    AppJsonContext.Default.MySettings);

The same overload is available for fallback configuration:

builder.Configuration.AddObjectAsFallback(
    defaults,
    AppJsonContext.Default.MySettings);

API

IConfigurationBuilder AddObject<T>(
    T? value,
    string? rootSectionName = "");

IConfigurationBuilder AddObject<T>(
    T? value,
    JsonTypeInfo<T> jsonTypeInfo,
    string? rootSectionName = "");

IConfigurationBuilder AddObjectAsFallback<T>(
    T? value,
    string? rootSectionName = "");

IConfigurationBuilder AddObjectAsFallback<T>(
    T? value,
    JsonTypeInfo<T> jsonTypeInfo,
    string? rootSectionName = "");

For source code, examples, and release notes, see the GitHub repository: https://github.com/Kralizek/ObjectConfigurationExtensions

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.  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 is compatible.  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. 
.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 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Kralizek.Extensions.Configuration.Objects:

Package Downloads
Kralizek.Extensions.Configuration.Objects.NewtonsoftJson

Extension of Kralizek.Extensions.Configuration using Newtonsoft.Json.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 99 8/27/2026
4.0.0-rc.1 64 8/24/2026
4.0.0-beta.2 53 8/24/2026
4.0.0-beta.1 55 8/22/2026
3.0.1 6,086 7/12/2024
3.0.0 2,295 1/30/2024
2.0.1 7,214 6/16/2021
2.0.0 1,924 6/10/2021
1.0.1 5,464 11/29/2019
1.0.0 891 11/3/2019