Search Results for

    Show / Hide Table of Contents

    Interface IConfigurationService

    A service that gets and sets configuration settings.

    See AConfig Configuration Facility, AConfig, and JsonConfigurationService for further details.

    Namespace: actionETL.Configuration
    Assembly: actionETL.dll
    Syntax
    public interface IConfigurationService

    Methods

    SetValue(String, String, String)

    Creates or updates a configuration value.

    This method must be thread-safe.

    Declaration
    IConfigurationService SetValue(string configurationName, string applyTo, string valueString)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    String applyTo

    What part of the worker hierarchy this configuration applies to. Use null or an empty string to set a value that applies globally.

    String valueString

    The value as a string.

    Returns
    Type Description
    IConfigurationService

    The IConfigurationService instance itself, to allow chaining multiple calls together.

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    TryGetValue<T>(String, String, CultureInfo)

    Attempts to get a configuration value, returning an IGetValueOutcome instance describing the outcome. To instead throw an exception on any failure, use the AConfig GetValue and GetValueWithDefault methods.

    On success, ApplyToMatched describes whether ApplyTo was both used and matched, or not. This is typically used to give configurations with ApplyTo higher precedence vs. non-ApplyTo configurations.

    This method must be thread-safe.

    Declaration
    IGetValueOutcome TryGetValue<T>(string configurationName, string applyTo, CultureInfo culture)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration. Cannot be null or only whitespace.

    String applyTo

    What part of the worker hierarchy the configuration applies to. If set, first looks for a matching configurationName with a matching applyTo. If not found, then looks for a matching configurationName without any applyTo.

    Use null or an empty string to only look for a global configuration value without an applyTo.

    CultureInfo culture

    The culture to use when converting a string to a typed value. Defaults to InvariantCulture if null.

    Returns
    Type Description
    IGetValueOutcome

    The outcome is returned in a class instance derived from IGetValueOutcome:

    • GetValueOutcome.Succeeded on success, with the value available in Value. ApplyToMatched describes whether 'ApplyTo' was both used and matched, or not.
    • GetValueOutcome.NotFound if the configurationName parameter either cannot be found at all, or it was found but only with a non-matching applyTo.
    • GetValueOutcome.ParseError if parsing the string to the target type failed, with Exception describing the failure
    • GetValueOutcome.NotSupported if converting to the target type T is not supported

    Typical usage is to call TryGetValue and switch on the type of the returned instance.

    Type Parameters
    Name Description
    T

    The target value type. TryGetValue<T>(String, String, CultureInfo) describes what types the default service supports.

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    See Also

    JsonConfigurationService
    AConfig
    In This Article
    Back to top Copyright © 2023 Envobi Ltd