Obtain settings from provider

Requires: main module.

Settings can be obtained on-demand with configuration provider's Get method.

With prior assignment of sources:

var settings = provider.Get<MySettings>();

With sources passed on per-call basis:

var settings = provider.Get<MySettings>(new JsonFileSource("settings.json"));

Get method behavior

  • Always returns the most recent version of settings (updates may happen in background):

    • Call Get on every settings access for "hot" configuration;

    • Call Get once and cache the result for "cold" configuration;

  • First call for a type may block or throw exceptions due to source latency, data unavailability or incorrect data format. This behavior persists until a data update remedies the error;

  • Once warmed up, subsequent calls never block or throw errors and are extremely cheap due to caching. Future errors are not propagated to the calling code, but can be logged. Get calls return the last seen correct settings object;

pageConfiguration providerpageConfiguration sourcespageCaching and performancepageError handling

Last updated