Linger.Configuration 0.7.2

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Linger.Configuration --version 0.7.2
                    
NuGet\Install-Package Linger.Configuration -Version 0.7.2
                    
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="Linger.Configuration" Version="0.7.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linger.Configuration" Version="0.7.2" />
                    
Directory.Packages.props
<PackageReference Include="Linger.Configuration" />
                    
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 Linger.Configuration --version 0.7.2
                    
#r "nuget: Linger.Configuration, 0.7.2"
                    
#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 Linger.Configuration@0.7.2
                    
#: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=Linger.Configuration&version=0.7.2
                    
Install as a Cake Addin
#tool nuget:?package=Linger.Configuration&version=0.7.2
                    
Install as a Cake Tool

Linger.Configuration

📝 View this document in: English | 中文

A lightweight configuration helper library for .NET applications.

Overview

Linger.Configuration provides utilities and extensions to simplify configuration management in .NET applications. It offers a consistent approach to access and bind configuration settings from various sources, with a focus on strongly-typed configuration.

Features

  • Simple singleton-based configuration access
  • Strong typing for configuration settings
  • Extension methods for IConfiguration
  • Support for JSON configuration files
  • Compatible with dependency injection
  • Cross-platform support

Installation

dotnet add package Linger.Configuration

Usage

Basic Usage

// Access configuration singleton
var config = AppConfig.Instance.Config;

// Get configuration values
string connectionString = config.GetConnectionString("DefaultConnection");
int timeoutSeconds = config.GetValue<int>("AppSettings:TimeoutSeconds");

// Bind to strongly-typed objects
var smtpSettings = config.GetSection("SmtpSettings").Get<SmtpSettings>();

Strongly-typed Configuration

public class AppSettings
{
    public string ApplicationName { get; set; }
    public int CacheTimeoutMinutes { get; set; }
    public bool EnableLogging { get; set; }
    public ConnectionStrings ConnectionStrings { get; set; }
}

public class ConnectionStrings
{
    public string DefaultConnection { get; set; }
    public string LoggingConnection { get; set; }
}

// Bind configuration
var appSettings = config.Get<AppSettings>();
Console.WriteLine($"App Name: {appSettings.ApplicationName}");
Console.WriteLine($"Cache Timeout: {appSettings.CacheTimeoutMinutes} minutes");

Using with Dependency Injection

// In Startup.cs or Program.cs
public void ConfigureServices(IServiceCollection services)
{
    // Add configuration
    services.AddSingleton<IConfiguration>(AppConfig.Instance.Config);
    
    // Register strongly-typed options
    services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
    
    // Use options pattern
    services.AddTransient<IMyService, MyService>();
}

// In a service
public class MyService : IMyService
{
    private readonly AppSettings _settings;
    
    public MyService(IOptions<AppSettings> options)
    {
        _settings = options.Value;
    }
    
    public void DoSomething()
    {
        // Use settings
        if (_settings.EnableLogging)
        {
            // Log something
        }
    }
}

Helper Methods

// Get a typed value with a default
int timeout = AppSettingsHelper.GetValue("TimeoutSeconds", 30);

// Get a connection string
string connStr = AppSettingsHelper.GetConnectionString("DefaultConnection");

// Get a complex configuration object
var emailSettings = AppSettingsHelper.GetSection<EmailSettings>("EmailConfiguration");

Dependencies

  • Microsoft.Extensions.Configuration.Binder
  • Microsoft.Extensions.Configuration.Json
  • Linger (Core utilities)

License

This project is licensed under the terms of the license provided with the Linger project.

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 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 is compatible.  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. 
.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 (2)

Showing the top 2 NuGet packages that depend on Linger.Configuration:

Package Downloads
Linger.Email.AspNetCore

ASP.NET Core integration for the Linger.Email library. Provides dependency injection extensions and configuration integration for email services. Simplifies email sending in modern ASP.NET Core applications.

Linger.AspNetCore.Jwt

A comprehensive JWT authentication implementation for ASP.NET Core applications. Provides JWT token generation, validation, and refresh token functionality with blacklisting support. Integrates seamlessly with ASP.NET Core authentication services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.0-preview 484 7/22/2025
0.7.2 153 6/3/2025
0.7.1 159 5/21/2025
0.7.0 156 5/19/2025
0.6.0-alpha 162 4/28/2025
0.5.0-alpha 162 4/10/2025
0.4.0-alpha 159 4/1/2025
0.3.3-alpha 156 3/19/2025
0.3.2-alpha 153 3/17/2025
0.3.1-alpha 141 3/16/2025
0.3.0-alpha 203 3/6/2025
0.2.0-alpha 101 2/9/2025
0.1.2-alpha 105 12/17/2024
0.1.1-alpha 101 12/17/2024
0.1.0-alpha 105 12/6/2024
0.0.3-alpha 128 8/9/2024
0.0.2-alpha 103 8/9/2024
0.0.1-alpha 91 8/7/2024