Search Results for

    Show / Hide Table of Contents

    Class AConfig

    Get and set configuration settings, e.g. folder and file names, URLs, system settings (dataflow buffer sizes etc.)

    Each worker system uses an AConfig instance via the Config property, but it can also be used stand-alone, without any worker system.

    See AConfig Configuration Facility and JsonConfigurationService for further details.

    Inheritance
    Object
    AConfig
    Namespace: actionETL.Configuration
    Assembly: actionETL.dll
    Syntax
    public class AConfig

    Constructors

    AConfig(IConfigurationService)

    Initializes a new instance of the AConfig class with the provided IConfigurationService.

    Declaration
    public AConfig(IConfigurationService configurationService)
    Parameters
    Type Name Description
    IConfigurationService configurationService

    The configuration service.

    Exceptions
    Type Condition
    ArgumentNullException

    configurationService

    See Also
    JsonConfigurationService

    Properties

    Item[String]

    Gets (with InvariantCulture) or sets/updates a global (i.e. no applyTo specified) configuration with a string value. This is a short-cut for the GetValue<string> and SetValue(..., string) methods. Do use GetValue / SetValue methods instead when retrieving non-string values, and when one of their additional arguments is needed.

    This indexer is thread-safe.

    Declaration
    public string this[string configurationName] { get; set; }
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    Property Value
    Type Description
    String

    The string value.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    Methods

    GetValue<T>(String)

    Gets a global (i.e. no applyTo specified) configuration value with InvariantCulture.

    This method is thread-safe.

    Declaration
    public T GetValue<T>(string configurationName)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValue<T>(String, CultureInfo)

    Gets a global (i.e. no applyTo specified) configuration value.

    This method is thread-safe.

    Declaration
    public T GetValue<T>(string configurationName, CultureInfo culture)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    CultureInfo culture

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

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValue<T>(String, String)

    Gets a configuration value with InvariantCulture.

    This method is thread-safe.

    Declaration
    public T GetValue<T>(string configurationName, string applyTo)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    String applyTo

    What part of the worker hierarchy the configuration applies to. Use null or an empty string to get the global value.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValue<T>(String, String, CultureInfo)

    Gets a configuration value.

    This method is thread-safe.

    Declaration
    public T GetValue<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. Use null or an empty string to get the global value.

    CultureInfo culture

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

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValueWithDefault<T>(String, T)

    Gets a global (i.e. no applyTo specified) configuration value with InvariantCulture, or a default value if no configuration found.

    This method is thread-safe.

    Declaration
    public T GetValueWithDefault<T>(string configurationName, T defaultValue)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    T defaultValue

    The default value.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValueWithDefault<T>(String, CultureInfo, T)

    Gets a global (i.e. no applyTo specified) configuration value, or a default value if no configuration found.

    This method is thread-safe.

    Declaration
    public T GetValueWithDefault<T>(string configurationName, CultureInfo culture, T defaultValue)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    CultureInfo culture

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

    T defaultValue

    The default value.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValueWithDefault<T>(String, String, T)

    Gets a configuration value with InvariantCulture, or a default value if no configuration found.

    This method is thread-safe.

    Declaration
    public T GetValueWithDefault<T>(string configurationName, string applyTo, T defaultValue)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    String applyTo

    What part of the worker hierarchy the configuration applies to. Use null or an empty string to get the global value.

    T defaultValue

    The default value.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    GetValueWithDefault<T>(String, String, CultureInfo, T)

    Gets a configuration value, or a default value if no configuration found.

    This method is thread-safe.

    Declaration
    public T GetValueWithDefault<T>(string configurationName, string applyTo, CultureInfo culture, T defaultValue)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    String applyTo

    What part of the worker hierarchy the configuration applies to. Use null or an empty string to get the global value.

    CultureInfo culture

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

    T defaultValue

    The default value.

    Returns
    Type Description
    T

    The typed value.

    Type Parameters
    Name Description
    T

    The target value type. See TryGetValue<T>(String, String, CultureInfo) for types supported by the default configuration service.

    Exceptions
    Type Condition
    ArgumentException
    • configurationName cannot be null or only whitespace.
    • Configuration configurationName not found.
    FormatException

    Parse error converting configuration to type T.

    NotSupportedException

    Converting to type T is not supported.

    SetValue(String, Int64)

    Creates or updates a global (i.e. no applyTo specified) configuration value.

    This method is thread-safe.

    Declaration
    public AConfig SetValue(string configurationName, long valueInt64)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    Int64 valueInt64

    The value as an integer.

    Returns
    Type Description
    AConfig

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

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    InvalidOperationException

    Cannot set this configuration after creating the worker system. Instead create and inject the configuration service explicitly, please see the documentation.

    SetValue(String, String)

    Creates or updates a global (i.e. no applyTo specified) configuration value.

    This method is thread-safe.

    Declaration
    public AConfig SetValue(string configurationName, string valueString)
    Parameters
    Type Name Description
    String configurationName

    Name of the configuration.

    String valueString

    The value as a string.

    Returns
    Type Description
    AConfig

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

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    InvalidOperationException

    Cannot set this configuration after creating the worker system. Instead create and inject the configuration service explicitly, please see the documentation.

    SetValue(String, String, Int64)

    Creates or updates a configuration value.

    This method is thread-safe.

    Declaration
    public AConfig SetValue(string configurationName, string applyTo, long valueInt64)
    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.

    Int64 valueInt64

    The value as an integer.

    Returns
    Type Description
    AConfig

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

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    InvalidOperationException

    Cannot set this configuration after creating the worker system. Instead create and inject the configuration service explicitly, please see the documentation.

    SetValue(String, String, String)

    Creates or updates a configuration value.

    This method is thread-safe.

    Declaration
    public AConfig 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
    AConfig

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

    Exceptions
    Type Condition
    ArgumentException

    configurationName cannot be null or only whitespace.

    InvalidOperationException

    Cannot set this configuration after creating the worker system. Instead create and inject the configuration service explicitly, please see the documentation.

    ToString()

    Returns a String that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Object.ToString()

    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.

    Where possible, do use the simpler GetValue() and GetValueWithDefault() overloads.

    This method is thread-safe.

    Declaration
    public 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. Use null or an empty string to get the global value.

    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
    • GetValueOutcome.NotFound if the configurationName parameter or, if set, applyTo parameter cannot be found
    • 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

    IConfigurationService
    JsonConfigurationService
    Config
    In This Article
    Back to top Copyright © 2021 Envobi Ltd