ReloadableConfiguration 1.1.0
See the version list below for details.
dotnet add package ReloadableConfiguration --version 1.1.0
NuGet\Install-Package ReloadableConfiguration -Version 1.1.0
<PackageReference Include="ReloadableConfiguration" Version="1.1.0" />
<PackageVersion Include="ReloadableConfiguration" Version="1.1.0" />
<PackageReference Include="ReloadableConfiguration" />
paket add ReloadableConfiguration --version 1.1.0
#r "nuget: ReloadableConfiguration, 1.1.0"
#:package ReloadableConfiguration@1.1.0
#addin nuget:?package=ReloadableConfiguration&version=1.1.0
#tool nuget:?package=ReloadableConfiguration&version=1.1.0
ReloadableConfiguration
An ASP .NET Core class library for defining reloadable configuration repositories that periodically reload their contents to reflect data changes made by others.
Installation:
- from NuGet;
- from package manager console:
Install-Package ReloadableConfiguration
- from command line:
dotnet add package ReloadableConfiguration
Usage:
- The source of reloadable configuration repository provider should have
PeriodicalReload
property set totrue
. This may be done by callingWithPeriodicalReload()
extension method on source configurator. - A
ConfigurationReloader
hosted service should be registered in service collection usingAddConfigurationReloader()
extension method.
Examples:
The following sample explains how to define a configuration repository that is periodically reloaded to update it`s configuration if provider data changes. A working example you may find in ReloadableRepository.ParsableInMemory sample project on github.
using ConfigurationRepository;
using Microsoft.AspNetCore.Builder;
var builder = WebApplication.CreateBuilder(args);
// Define our json configuration data.
var configJsonData = """{"JSON KEY": "JSON VALUE"}""";
// Create repository object with this data.
var repository = new InMemoryJsonRepository(configJsonData);
// Define our parsable json configuration provider with in-memory repository.
// Also configure configuration source that this configuration with be reloadable
// by ConfigurationReloader hosting servce.
builder.Configuration.AddParsableRepository(
repository,
configureSource: source => source.WithPeriodicalReload());
// Next call does two things:
// 1. Registers ConfigurationReloader hosted service in service collection.
// This hosted service periodically reloads it`s configuration providers.
// 2. Registers reloadable configuration service with builder.Configuration
// for ConfigurationReloader. This tells ConfigurationReloader wich providers
// he should serve.
// FYI: Reload period of 0.5 second is just for quick sample results.
builder.Services.AddConfigurationReloader(
builder.Configuration,
TimeSpan.FromSeconds(0.5));
var app = builder.Build();
app.Run();
// In memory configuration repository that takes a json and returns
// it to a configuration parser. JsonConfig can be set outside to
// simulate external repository changes. This class just demonstrates
// a minimal parsable repository implementation.
class InMemoryJsonRepository(string jsonConfig)
: IConfigurationRepository
{
public string JsonConfig { get; set; } = jsonConfig;
public TData GetConfiguration<TData>()
{
return (TData)Convert.ChangeType(JsonConfig, typeof(TData));
}
}
The complete example you may find in ReloadableRepository.ParsableInMemory project on github.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ReloadableConfiguration:
Package | Downloads |
---|---|
ConfigurationRepository
Configuration repository provider for building .NET Core application`s configuration stored in databases or other storages. |
|
ParametrizedConfiguration
Parametrized configuration provider. A configuration that may contain parameter placeholders replaceable with values. Parameter values substitute with keys from the same configuration. |
GitHub repositories
This package is not used by any popular GitHub repositories.