Microsoft.Extensions.Options.ConfigurationExtensions
9.0.0-preview.4.24266.19
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.Options.ConfigurationExtensions --version 9.0.0-preview.4.24266.19
NuGet\Install-Package Microsoft.Extensions.Options.ConfigurationExtensions -Version 9.0.0-preview.4.24266.19
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0-preview.4.24266.19" />
paket add Microsoft.Extensions.Options.ConfigurationExtensions --version 9.0.0-preview.4.24266.19
#r "nuget: Microsoft.Extensions.Options.ConfigurationExtensions, 9.0.0-preview.4.24266.19"
// Install Microsoft.Extensions.Options.ConfigurationExtensions as a Cake Addin #addin nuget:?package=Microsoft.Extensions.Options.ConfigurationExtensions&version=9.0.0-preview.4.24266.19&prerelease // Install Microsoft.Extensions.Options.ConfigurationExtensions as a Cake Tool #tool nuget:?package=Microsoft.Extensions.Options.ConfigurationExtensions&version=9.0.0-preview.4.24266.19&prerelease
About
Microsoft.Extensions.Options.ConfigurationExtensions
provides additional configuration-specific functionality related to Options.
Key Features
- Extension methods for OptionsBuilder for configuration binding
- Extension methods for IServiceCollection for Options configuration
- ConfigurationChangeTokenSource<TOptions> for monitoring configuration changes
How to Use
Options Configuration binding
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
class Program
{
// appsettings.json contents:
// {
// "MyOptions": {
// "Setting1": "Value1",
// "Setting2": "Value2"
// }
// }
static void Main(string[] args)
{
IConfiguration configuration = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("appsettings.json")
.Build();
IServiceCollection services = new ServiceCollection();
// Bind the configuration to MyOptions
services.Configure<MyOptions>(configuration.GetSection("MyOptions"));
IServiceProvider serviceProvider = services.BuildServiceProvider();
// Retrieve MyOptions using dependency injection
var myOptions = serviceProvider.GetRequiredService<IOptions<MyOptions>>().Value;
// Access the bound configuration values
Console.WriteLine($"Setting1: {myOptions.Setting1}");
Console.WriteLine($"Setting2: {myOptions.Setting2}");
}
}
public class MyOptions
{
public string Setting1 { get; set; }
public string Setting2 { get; set; }
}
Monitoring options configuration changes
// Assume we have a class that represents some options
public class MyOptions
{
public string Name { get; set; }
public int Age { get; set; }
}
// appsettings.json contents:
// {
// "MyOptions": {
// "Name": "Alice",
// "Age": 25
// }
// }
// Assume we have a configuration object that contains some settings
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
// We can use the ConfigurationChangeTokenSource to create a change token source for the options
var changeTokenSource = new ConfigurationChangeTokenSource<MyOptions>(config.GetSection("MyOptions"));
// We can register the change token source with the options monitor
services.AddOptions<MyOptions>()
.Configure(options =>
{
// Configure the options with the configuration values
config.GetSection("MyOptions").Bind(options);
})
.AddChangeTokenSource(changeTokenSource);
// Now we can inject the options monitor into any class that needs them
public class MyClass
{
private readonly IOptionsMonitor<MyOptions> _optionsMonitor;
public MyClass(IOptionsMonitor<MyOptions> optionsMonitor)
{
_optionsMonitor = optionsMonitor;
}
public void DoSomething()
{
// Can access the current options value like this
var options = _optionsMonitor.CurrentValue;
var name = options.Name;
var age = options.Age;
// Do something with name and age
// Can also register a callback to be notified when the options change
_optionsMonitor.OnChange(newOptions =>
{
// Do something when the options change
});
}
}
Main Types
The main types provided by this library are:
ConfigurationChangeTokenSource
OptionsBuilderConfigurationExtensions
OptionsConfigurationServiceCollectionExtensions
Additional Documentation
Related Packages
- Microsoft.Extensions.Options
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.DependencyInjection
Feedback & Contributing
Microsoft.Extensions.Options.ConfigurationExtensions is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Product | Versions 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. |
.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 is compatible. 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. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Options (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Primitives (>= 9.0.0-preview.4.24266.19)
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Options (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Primitives (>= 9.0.0-preview.4.24266.19)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Options (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Primitives (>= 9.0.0-preview.4.24266.19)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Options (>= 9.0.0-preview.4.24266.19)
- Microsoft.Extensions.Primitives (>= 9.0.0-preview.4.24266.19)
NuGet packages (3.7K)
Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Options.ConfigurationExtensions:
Package | Downloads |
---|---|
Microsoft.Extensions.Logging.Configuration
Configuration support for Microsoft.Extensions.Logging. |
|
Microsoft.Extensions.Diagnostics
This package includes the default implementation of IMeterFactory and additional extension methods to easily register it with the Dependency Injection framework. |
|
Microsoft.Identity.Web.TokenAcquisition
Implementation for higher level API for confidential client applications (ASP.NET Core and SDK/.NET). |
|
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. |
|
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. |
GitHub repositories (264)
Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.Options.ConfigurationExtensions:
Repository | Stars |
---|---|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
|
|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
chocolatey/choco
Chocolatey - the package manager for Windows
|
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 490,663 | 11/12/2024 | |
9.0.0-rc.2.24473.5 | 160,802 | 10/8/2024 | |
9.0.0-rc.1.24431.7 | 152,029 | 9/10/2024 | |
9.0.0-preview.7.24405.7 | 54,304 | 8/13/2024 | |
9.0.0-preview.6.24327.7 | 83,342 | 7/9/2024 | |
9.0.0-preview.5.24306.7 | 82,126 | 6/11/2024 | |
9.0.0-preview.4.24266.19 | 54,484 | 5/21/2024 | |
9.0.0-preview.3.24172.9 | 141,169 | 4/11/2024 | |
9.0.0-preview.2.24128.5 | 69,463 | 3/12/2024 | |
9.0.0-preview.1.24080.9 | 71,737 | 2/13/2024 | |
8.0.0 | 135,381,024 | 11/14/2023 | |
8.0.0-rc.2.23479.6 | 1,038,342 | 10/10/2023 | |
8.0.0-rc.1.23419.4 | 360,609 | 9/12/2023 | |
8.0.0-preview.7.23375.6 | 353,878 | 8/8/2023 | |
8.0.0-preview.6.23329.7 | 94,229 | 7/11/2023 | |
8.0.0-preview.5.23280.8 | 67,267 | 6/13/2023 | |
8.0.0-preview.4.23259.5 | 228,759 | 5/16/2023 | |
8.0.0-preview.3.23174.8 | 108,527 | 4/11/2023 | |
8.0.0-preview.2.23128.3 | 52,407 | 3/14/2023 | |
8.0.0-preview.1.23110.8 | 102,115 | 2/21/2023 | |
7.0.0 | 108,207,174 | 11/7/2022 | |
7.0.0-rc.2.22472.3 | 173,442 | 10/11/2022 | |
7.0.0-rc.1.22426.10 | 82,237 | 9/14/2022 | |
7.0.0-preview.7.22375.6 | 64,199 | 8/9/2022 | |
7.0.0-preview.6.22324.4 | 60,881 | 7/12/2022 | |
7.0.0-preview.5.22301.12 | 48,475 | 6/14/2022 | |
7.0.0-preview.4.22229.4 | 57,565 | 5/10/2022 | |
7.0.0-preview.3.22175.4 | 52,998 | 4/13/2022 | |
7.0.0-preview.2.22152.2 | 15,935 | 3/14/2022 | |
7.0.0-preview.1.22076.8 | 31,275 | 2/17/2022 | |
6.0.1 | 15,556 | 11/12/2024 | |
6.0.0 | 270,489,350 | 11/8/2021 | |
6.0.0-rc.2.21480.5 | 402,088 | 10/12/2021 | |
6.0.0-rc.1.21451.13 | 283,736 | 9/14/2021 | |
6.0.0-preview.7.21377.19 | 150,713 | 8/10/2021 | |
6.0.0-preview.6.21352.12 | 88,610 | 7/14/2021 | |
6.0.0-preview.5.21301.5 | 40,192 | 6/15/2021 | |
6.0.0-preview.4.21253.7 | 32,799 | 5/24/2021 | |
6.0.0-preview.3.21201.4 | 56,770 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 83,548 | 3/11/2021 | |
6.0.0-preview.1.21102.12 | 68,258 | 2/12/2021 | |
5.0.0 | 169,407,808 | 11/9/2020 | |
5.0.0-rc.2.20475.5 | 129,160 | 10/13/2020 | |
5.0.0-rc.1.20451.14 | 268,387 | 9/14/2020 | |
5.0.0-preview.8.20407.11 | 316,087 | 8/25/2020 | |
5.0.0-preview.7.20364.11 | 44,249 | 7/21/2020 | |
5.0.0-preview.6.20305.6 | 43,266 | 6/25/2020 | |
5.0.0-preview.5.20278.1 | 22,130 | 6/10/2020 | |
5.0.0-preview.4.20251.6 | 35,330 | 5/18/2020 | |
5.0.0-preview.3.20215.2 | 31,283 | 4/23/2020 | |
5.0.0-preview.2.20160.3 | 54,481 | 4/2/2020 | |
5.0.0-preview.1.20120.4 | 32,058 | 3/16/2020 | |
3.1.32 | 4,808,604 | 12/13/2022 | |
3.1.31 | 1,042,730 | 11/8/2022 | |
3.1.30 | 1,401,374 | 10/11/2022 | |
3.1.29 | 603,616 | 9/13/2022 | |
3.1.28 | 1,049,600 | 8/9/2022 | |
3.1.27 | 1,088,890 | 7/12/2022 | |
3.1.26 | 597,021 | 6/14/2022 | |
3.1.25 | 1,193,327 | 5/10/2022 | |
3.1.24 | 683,156 | 4/11/2022 | |
3.1.23 | 1,698,113 | 3/8/2022 | |
3.1.22 | 10,507,788 | 12/14/2021 | |
3.1.21 | 3,427,772 | 11/7/2021 | |
3.1.20 | 1,406,093 | 10/11/2021 | |
3.1.19 | 1,554,874 | 9/14/2021 | |
3.1.18 | 3,401,824 | 8/10/2021 | |
3.1.17 | 2,586,578 | 7/13/2021 | |
3.1.16 | 2,637,434 | 6/8/2021 | |
3.1.15 | 4,106,171 | 5/11/2021 | |
3.1.14 | 9,500,882 | 4/6/2021 | |
3.1.13 | 6,393,050 | 3/9/2021 | |
3.1.12 | 4,331,459 | 2/9/2021 | |
3.1.11 | 5,308,226 | 1/12/2021 | |
3.1.10 | 11,126,041 | 11/9/2020 | |
3.1.9 | 12,556,744 | 10/13/2020 | |
3.1.8 | 17,413,445 | 9/8/2020 | |
3.1.7 | 10,282,357 | 8/11/2020 | |
3.1.6 | 18,698,198 | 7/14/2020 | |
3.1.5 | 18,262,279 | 6/9/2020 | |
3.1.4 | 12,029,186 | 5/12/2020 | |
3.1.3 | 19,148,946 | 3/24/2020 | |
3.1.2 | 17,867,914 | 2/18/2020 | |
3.1.1 | 14,719,476 | 1/14/2020 | |
3.1.0 | 101,280,454 | 12/3/2019 | |
3.1.0-preview3.19553.2 | 56,256 | 11/13/2019 | |
3.1.0-preview2.19525.4 | 15,778 | 11/1/2019 | |
3.1.0-preview1.19506.1 | 18,920 | 10/15/2019 | |
3.0.3 | 589,676 | 2/18/2020 | |
3.0.2 | 785,615 | 1/14/2020 | |
3.0.1 | 2,186,756 | 11/18/2019 | |
3.0.0 | 33,417,830 | 9/23/2019 | |
3.0.0-rc1.19456.10 | 35,151 | 9/16/2019 | |
3.0.0-preview9.19423.4 | 134,309 | 9/4/2019 | |
3.0.0-preview8.19405.4 | 150,419 | 8/13/2019 | |
3.0.0-preview7.19362.4 | 77,968 | 7/23/2019 | |
3.0.0-preview6.19304.6 | 143,891 | 6/12/2019 | |
3.0.0-preview5.19227.9 | 156,473 | 5/6/2019 | |
3.0.0-preview4.19216.2 | 23,610 | 4/18/2019 | |
3.0.0-preview3.19153.1 | 151,282 | 3/6/2019 | |
3.0.0-preview.19074.2 | 96,011 | 1/29/2019 | |
3.0.0-preview.18572.1 | 10,961 | 12/4/2018 | |
2.2.0 | 85,702,834 | 12/3/2018 | |
2.2.0-preview3-35497 | 140,362 | 10/17/2018 | |
2.2.0-preview2-35157 | 64,757 | 9/12/2018 | |
2.2.0-preview1-35029 | 34,561 | 8/22/2018 | |
2.1.1 | 64,417,822 | 6/18/2018 | |
2.1.0 | 182,549,345 | 5/29/2018 | |
2.1.0-rc1-final | 75,757 | 5/6/2018 | |
2.1.0-preview2-final | 67,181 | 4/10/2018 | |
2.1.0-preview1-final | 160,166 | 2/26/2018 | |
2.0.2 | 6,116,079 | 5/7/2018 | |
2.0.1 | 10,360,919 | 3/13/2018 | |
2.0.0 | 344,109,507 | 8/11/2017 | |
2.0.0-preview2-final | 123,977 | 6/28/2017 | |
2.0.0-preview1-final | 39,622 | 5/10/2017 | |
1.1.2 | 8,055,959 | 5/9/2017 | |
1.1.1 | 2,767,911 | 3/6/2017 | |
1.1.0 | 2,356,601 | 11/16/2016 | |
1.1.0-preview1-final | 15,637 | 10/24/2016 | |
1.0.2 | 709,661 | 3/6/2017 | |
1.0.1 | 253,181 | 12/12/2016 | |
1.0.0 | 2,066,522 | 6/27/2016 | |
1.0.0-rc2-final | 23,664 | 5/16/2016 |