RazorDocs Search

Config

Type

DefaultConfigFileLocationProvider

Default implementation of IConfigFileLocationProvider that uses the application's base directory.

Type

EnvironmentConfigProvider

A configuration provider that retrieves values from environment variables.

Method

NormalizeSegment

string NormalizeSegment(string value)

Converts a key/environment segment to uppercase (via string.ToUpperInvariant) and flattens separators by replacing '.' and '-' with a single '_'. Used for legacy flat environment-variable lookup.

Method

NormalizeHierarchicalKey

string NormalizeHierarchicalKey(string value)

Converts a key to uppercase (via string.ToUpperInvariant), splits on '.' and '-' as hierarchical delimiters, removes empty segments, and joins segments using "__". Used for hierarchical environment-variable lookup while preserving path boundaries.

Type

IConfigManager

Defines the central manager for configuration, which aggregates multiple IConfigProvider instances.

Type

IConfigFileLocationProvider

Provides the directory path where configuration files are located.

Property

Directory

string Directory { get; }

Gets the directory path containing configuration files.

Type

FileBasedConfigProvider

A configuration provider that reads settings from JSON files (e.g., appsettings.json, config_*.json).

Type

ConfigStruct<T>

A base class for strongly-typed configuration objects where the value is a struct.

Type Parameters

  • TThe struct type of the configuration value.
Property

HasValue

bool HasValue { get; set; }

Gets a value indicating whether the configuration has a value.

Property

IsDefaultValue

bool IsDefaultValue { get; set; }

Gets a value indicating whether the current value is the default value.

Property

Value

T? Value { get; set; }

Gets the configuration value.

Property

DefaultValue

T? DefaultValue { get; }

Gets the default value for the configuration if none is found in the source.

Type

RunnableConfigModule

A module that registers configuration management services and automatically discovers and registers configuration objects.

Type

ConfigKeyAttribute

Specifies the configuration key or path for a type.

Method

ExtractKey

2 overloads
string? ExtractKey(object obj)

Extracts the configuration key from an object's type attribute.

Parameters

  • objThe object to extract the key from.

Returns

The configuration key, or null if not specified.

string? ExtractKey(Type type)

Extracts the configuration key from a type's attribute.

Parameters

  • typeThe type to extract the key from.

Returns

The configuration key, or null if not specified.

Method

GetKeyPath

string GetKeyPath(Type type)

Computes the full configuration key path for a type, recursively including declaring types unless Root is true.

Parameters

  • typeThe type to compute the path for.

Returns

The computed configuration key path.

Property

Key

string Key { get; }

Gets the configuration key or path for this type.

Property

Root

bool Root { get; }

Gets a value indicating whether this key should be treated as a root key, ignoring the declaring type hierarchy.

Type

IConfigProvider

Defines a provider that can retrieve configuration values.

Method

GetValue

T? GetValue<T>(string environment, string key)

Retrieves a configuration value for a specific environment and key.

Type Parameters

  • TThe type of the configuration value.

Parameters

  • environmentThe environment name (e.g., "Production").
  • keyThe configuration key.

Returns

The configuration value, or the default value of T if not found.

Property

Priority

int Priority { get; }

Higher number means higher priority. When multiple providers provide the same key, the one with the highest priority wins.

Property

Name

string Name { get; }

Gets the name of the configuration provider.

Type

IEnvironmentConfigProvider

Defines a configuration provider that also provides environment information.

Type

Config<T>

A base class for strongly-typed configuration objects.

Type Parameters

  • TThe type of the configuration value.
Property

HasValue

bool HasValue { get; set; }

Gets a value indicating whether the configuration has a value (either from source or default).

Property

IsDefaultValue

bool IsDefaultValue { get; set; }

Gets a value indicating whether the current value is the default value.

Property

Value

T? Value { get; set; }

Gets the configuration value.

Property

DefaultValue

T? DefaultValue { get; }

Gets the default value for the configuration if none is found in the source.

Type

DefaultConfigManager

Default implementation of IConfigManager that aggregates configuration from multiple sources.

Method

LogKeyNotFound

void LogKeyNotFound(string key, string environment)

Logs that a configuration key was not found.

Parameters

  • keyThe configuration key.
  • environmentThe environment name.
Method

LogRetrievedFromEnvironment

void LogRetrievedFromEnvironment(string key, string environment, string source)

Logs that a configuration key was retrieved from a specific source.

Parameters

  • keyThe configuration key.
  • environmentThe environment name.
  • sourceThe source of the configuration value.
Type

IConfig

Defines a configuration object that can be initialized using a configuration manager.

Method

Init

void Init(IConfigManager configManager, IEnvironmentProvider environmentProvider, string key)

Initializes the configuration object.

Parameters

  • configManagerThe configuration manager to use for retrieving values.
  • environmentProviderThe environment provider.
  • keyThe root configuration key for this object.