Class ConfigurationExt

Namespace: ArmoniK.Api.Common.Utils
Assembly: ArmoniK.Api.Common.dll

Extends the functionality of the

public static class ConfigurationExt

Inheritance

objectConfigurationExt

Inherited Members

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object, object), object.ToString()

Methods

GetRequiredValue<T>(IConfiguration, string)

Configure an object with the given configuration.

public static T GetRequiredValue<T>(this IConfiguration configuration, string key)

Parameters

configuration IConfiguration

Configurations used to populate the class

key string

Path to the Object in the configuration

Returns

T

The initialized object

Type Parameters

T

Type of the options class

Exceptions

InvalidOperationException

the key is not found in the configurations.

GetTimeSpanOrDefault(IConfiguration, string, TimeSpan)

Retrieves a from the configuration, or returns the provided default value if not found or invalid. If the configuration contains “MaxValue”, it will return .

public static TimeSpan GetTimeSpanOrDefault(this IConfiguration configuration, string key, TimeSpan defaultValue)

Parameters

configuration IConfiguration

The instance from which to retrieve the value.

key string

The key of the configuration value to retrieve.

defaultValue TimeSpan

The default value to return if the key is not found or the value is invalid.

Returns

TimeSpan

A representing the configuration value, or defaultValue if invalid or missing.

Exceptions

FormatException

Thrown if the value is not a valid or “MaxValue”.