Neovolve.Configuration.DependencyInjection
1.0.1-beta0001
See the version list below for details.
dotnet add package Neovolve.Configuration.DependencyInjection --version 1.0.1-beta0001
NuGet\Install-Package Neovolve.Configuration.DependencyInjection -Version 1.0.1-beta0001
<PackageReference Include="Neovolve.Configuration.DependencyInjection" Version="1.0.1-beta0001" />
paket add Neovolve.Configuration.DependencyInjection --version 1.0.1-beta0001
#r "nuget: Neovolve.Configuration.DependencyInjection, 1.0.1-beta0001"
// Install Neovolve.Configuration.DependencyInjection as a Cake Addin #addin nuget:?package=Neovolve.Configuration.DependencyInjection&version=1.0.1-beta0001&prerelease // Install Neovolve.Configuration.DependencyInjection as a Cake Tool #tool nuget:?package=Neovolve.Configuration.DependencyInjection&version=1.0.1-beta0001&prerelease
Introduction
The Neovolve.Configuration.DependencyInjection NuGet package provides IHostBuilder
extension methods for adding dependency injection support for nested configuration types with hot reload support.
Installation
The package can be installed from NuGet using Install-Package Neovolve.Configuration.DependencyInjection
.
Usage
Limitations
This extension uses type information to recurse through all the available properties and their types defined against the root configuration type. If any of the property types are defined as interfaces then the extension will register configuration types according to those interface definitions rather than any concrete type that the property may hold at runtime. This reason for this is that the extesion does not bind the configuration objects to recurse through the runtime configuration data but instead relies purely on the type information.
For example consider the following type structure:
public interface IConfig
{
string RootValue { get; }
}
public class Config : IConfig
{
public IFirstConfig First { get; } = new FirstConfig();
public string RootValue { get; set; }
}
public interface IFirstConfig
{
string FirstValue { get; }
}
public class FirstConfig : IFirstConfig
{
public string FirstValue { get; set; }
public SecondConfig Second { get; } = new();
}
public interface ISecondConfig
{
string SecondValue { get; }
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Host.ConfigureWith<Config>();
Using this extension on Config
would result in the following service registrations:
Config
IConfig
IOptions<Config>
IOptions<IConfig>
ISnapshotOptions<Config>
ISnapshotOptions<IConfig>
IMonitorOptions<Config>
IMonitorOptions<IConfig>
IOptions<FirstConfig>
IOptions<IFirstConfig>
ISnapshotOptions<FirstConfig>
ISnapshotOptions<IFirstConfig>
MonitorOptions<FirstConfig>
IMonitorOptions<IFirstConfig>
There would be no registrations for the following types:
IOptions<SecondConfig>
IOptions<ISecondConfig>
ISnapshotOptions<SecondConfig>
ISnapshotOptions<ISecondConfig>
MonitorOptions<SecondConfig>
IMonitorOptions<ISecondConfig>
You will need to define the properties on configuration types that provides the greatest reach of type information possible. The additional types above would be registered if the config class defined the First
property type as FirstConfig
rather than IFirstConfig
.
public class Config : IConfig
{
public FirstConfig First { get; } = new FirstConfig();
public string RootValue { get; set; }
}
When Config.First
is FirstConfig
rather than IFirstConfig
then the type searching logic can find the Second
property on FirstConfig
which is not defined on the interface.
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 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 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Binder (>= 7.0.4)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
- Microsoft.Extensions.Options (>= 7.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
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 |
---|---|---|
1.4.0 | 176 | 8/4/2024 |
1.3.2-beta0001 | 83 | 6/9/2024 |
1.3.1 | 118 | 5/23/2024 |
1.3.1-beta0001 | 100 | 5/23/2024 |
1.3.0 | 101 | 5/23/2024 |
1.3.0-beta0002 | 83 | 5/23/2024 |
1.2.1-beta0001 | 89 | 5/23/2024 |
1.2.0 | 160 | 4/13/2024 |
1.2.0-beta0002 | 102 | 4/13/2024 |
1.2.0-beta0001 | 93 | 4/13/2024 |
1.1.0 | 138 | 9/28/2023 |
1.0.1-beta0001 | 101 | 9/28/2023 |
0.1.0-beta0006 | 110 | 9/26/2023 |
0.1.0-beta0003 | 127 | 8/30/2023 |
0.1.0-beta0001 | 135 | 8/30/2023 |