Search Results for

    Show / Hide Table of Contents

    Class Config

    This class represents the main configuration object used by Akka.NET when configuring objects within the system. To put it simply, it's the internal representation of a HOCON (Human-Optimized Config Object Notation) configuration string.

    Inheritance
    object
    Config
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Akka.Configuration
    Assembly: Akka.dll
    Syntax
    public class Config

    Constructors

    | Edit this page View Source

    Config()

    Initializes a new instance of the Config class.

    Declaration
    public Config()
    | Edit this page View Source

    Config(Config, Config)

    Initializes a new instance of the Config class.

    Declaration
    public Config(Config source, Config fallback)
    Parameters
    Type Name Description
    Config source

    The configuration to use as the primary source.

    Config fallback

    The configuration to use as a secondary source.

    Exceptions
    Type Condition
    ArgumentNullException

    This exception is thrown if the given source is undefined.

    | Edit this page View Source

    Config(HoconRoot)

    Initializes a new instance of the Config class.

    Declaration
    public Config(HoconRoot root)
    Parameters
    Type Name Description
    HoconRoot root

    The root node to base this configuration.

    Exceptions
    Type Condition
    ArgumentNullException

    This exception is thrown if the given root value is undefined.

    Fields

    | Edit this page View Source

    Empty

    A static "Empty" configuration we can use instead of null in some key areas.

    Declaration
    public static readonly Config Empty
    Field Value
    Type Description
    Config

    Properties

    | Edit this page View Source

    Fallback

    The configuration used as a secondary source.

    Declaration
    public Config Fallback { get; }
    Property Value
    Type Description
    Config
    | Edit this page View Source

    IsEmpty

    Determines if this root node contains any values

    Declaration
    public virtual bool IsEmpty { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Root

    The root node of this configuration section

    Declaration
    public virtual HoconValue Root { get; }
    Property Value
    Type Description
    HoconValue
    | Edit this page View Source

    Substitutions

    An enumeration of substitutions values

    Declaration
    public IEnumerable<HoconSubstitution> Substitutions { get; set; }
    Property Value
    Type Description
    IEnumerable<HoconSubstitution>

    Methods

    | Edit this page View Source

    AsEnumerable()

    Retrieves an enumerable key value pair representation of the current configuration.

    Declaration
    public virtual IEnumerable<KeyValuePair<string, HoconValue>> AsEnumerable()
    Returns
    Type Description
    IEnumerable<KeyValuePair<string, HoconValue>>

    The current configuration represented as an enumerable key value pair.

    | Edit this page View Source

    Copy(Config)

    Generates a deep clone of the current configuration.

    Declaration
    protected Config Copy(Config fallback = null)
    Parameters
    Type Name Description
    Config fallback
    Returns
    Type Description
    Config

    A deep clone of the current configuration

    | Edit this page View Source

    GetBoolean(string, bool)

    Retrieves a boolean value from the specified path in the configuration.

    Declaration
    public virtual bool GetBoolean(string path, bool @default = false)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    bool default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    bool

    The boolean value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetBooleanList(string)

    Retrieves a list of boolean values from the specified path in the configuration.

    Declaration
    public virtual IList<bool> GetBooleanList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<bool>

    The list of boolean values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetByteList(string)

    Retrieves a list of byte values from the specified path in the configuration.

    Declaration
    public virtual IList<byte> GetByteList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<byte>

    The list of byte values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetByteSize(string)

    Retrieves a long value, optionally suffixed with a 'b', from the specified path in the configuration.

    Declaration
    public virtual long? GetByteSize(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    Returns
    Type Description
    long?

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetByteSize(string, long?)

    Retrieves a long value, optionally suffixed with a 'b', from the specified path in the configuration.

    Declaration
    public virtual long? GetByteSize(string path, long? def = null)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    long? def

    Default return value if none provided.

    Returns
    Type Description
    long?

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetConfig(string)

    Retrieves a new configuration from the current configuration with the root node being the supplied path.

    Declaration
    public virtual Config GetConfig(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the configuration to retrieve.

    Returns
    Type Description
    Config

    A new configuration with the root node being the supplied path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetDecimal(string, decimal)

    Retrieves a decimal value from the specified path in the configuration.

    Declaration
    public virtual decimal GetDecimal(string path, decimal @default = 0)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    decimal default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    decimal

    The decimal value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetDecimalList(string)

    Retrieves a list of decimal values from the specified path in the configuration.

    Declaration
    public virtual IList<decimal> GetDecimalList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<decimal>

    The list of decimal values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetDouble(string, double)

    Retrieves a double value from the specified path in the configuration.

    Declaration
    public virtual double GetDouble(string path, double @default = 0)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    double default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    double

    The double value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetDoubleList(string)

    Retrieves a list of double values from the specified path in the configuration.

    Declaration
    public virtual IList<double> GetDoubleList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<double>

    The list of double values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetFloat(string, float)

    Retrieves a float value from the specified path in the configuration.

    Declaration
    public virtual float GetFloat(string path, float @default = 0)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    float default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    float

    The float value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetFloatList(string)

    Retrieves a list of float values from the specified path in the configuration.

    Declaration
    public virtual IList<float> GetFloatList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<float>

    The list of float values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetInt(string, int)

    Retrieves an integer value from the specified path in the configuration.

    Declaration
    public virtual int GetInt(string path, int @default = 0)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    int default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    int

    The integer value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetIntList(string)

    Retrieves a list of int values from the specified path in the configuration.

    Declaration
    public virtual IList<int> GetIntList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<int>

    The list of int values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetLong(string, long)

    Retrieves a long value from the specified path in the configuration.

    Declaration
    public virtual long GetLong(string path, long @default = 0)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    long default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    long

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetLongList(string)

    Retrieves a list of long values from the specified path in the configuration.

    Declaration
    public virtual IList<long> GetLongList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<long>

    The list of long values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetString(string, string)

    Retrieves a string value from the specified path in the configuration.

    Declaration
    public virtual string GetString(string path, string @default = null)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    string default

    The default value to return if the value doesn't exist.

    Returns
    Type Description
    string

    The string value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetStringList(string)

    Retrieves a list of string values from the specified path in the configuration.

    Declaration
    public virtual IList<string> GetStringList(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    Returns
    Type Description
    IList<string>

    The list of string values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetStringList(string, string[])

    Retrieves a list of string values from the specified path in the configuration.

    Declaration
    public virtual IList<string> GetStringList(string path, string[] defaultPaths)
    Parameters
    Type Name Description
    string path

    The path that contains the values to retrieve.

    string[] defaultPaths

    Default paths that will be returned to the user.

    Returns
    Type Description
    IList<string>

    The list of string values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetTimeSpan(string, TimeSpan?, bool)

    Retrieves a TimeSpan value from the specified path in the configuration.

    Declaration
    public virtual TimeSpan GetTimeSpan(string path, TimeSpan? @default = null, bool allowInfinite = true)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    TimeSpan? default

    The default value to return if the value doesn't exist.

    bool allowInfinite

    true if infinite timespans are allowed; otherwise false.

    Returns
    Type Description
    TimeSpan

    The TimeSpan value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    GetValue(string)

    Retrieves a HoconValue from a specific path.

    Declaration
    public HoconValue GetValue(string path)
    Parameters
    Type Name Description
    string path

    The path that contains the value to retrieve.

    Returns
    Type Description
    HoconValue

    The HoconValue found at the location if one exists, otherwise null.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    HasPath(string)

    Determine if a HOCON configuration element exists at the specified location

    Declaration
    public virtual bool HasPath(string path)
    Parameters
    Type Name Description
    string path

    The location to check for a configuration value.

    Returns
    Type Description
    bool

    true if a value was found, false otherwise.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Edit this page View Source

    ToString()

    Converts the current configuration to a string.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string containing the current configuration.

    Overrides
    object.ToString()
    | Edit this page View Source

    ToString(bool)

    Converts the current configuration to a string

    Declaration
    public string ToString(bool includeFallback)
    Parameters
    Type Name Description
    bool includeFallback

    if true returns string with current config combined with fallback key-values else only current config key-values

    Returns
    Type Description
    string

    TBD

    | Edit this page View Source

    WithFallback(Config)

    Configure the current configuration with a secondary source.

    Declaration
    public virtual Config WithFallback(Config fallback)
    Parameters
    Type Name Description
    Config fallback

    The configuration to use as a secondary source.

    Returns
    Type Description
    Config

    The current configuration configured with the specified fallback.

    Exceptions
    Type Condition
    ArgumentException

    This exception is thrown if the given fallback is a reference to this instance.

    Operators

    | Edit this page View Source

    operator +(Config, string)

    Adds the supplied configuration string as a fallback to the supplied configuration.

    Declaration
    public static Config operator +(Config config, string fallback)
    Parameters
    Type Name Description
    Config config

    The configuration used as the source.

    string fallback

    The string used as the fallback configuration.

    Returns
    Type Description
    Config

    The supplied configuration configured with the supplied fallback.

    | Edit this page View Source

    operator +(string, Config)

    Adds the supplied configuration as a fallback to the supplied configuration string.

    Declaration
    public static Config operator +(string configHocon, Config fallbackConfig)
    Parameters
    Type Name Description
    string configHocon

    The configuration string used as the source.

    Config fallbackConfig

    The configuration used as the fallback.

    Returns
    Type Description
    Config

    A configuration configured with the supplied fallback.

    | Edit this page View Source

    implicit operator Config(string)

    Performs an implicit conversion from string to Config.

    Declaration
    public static implicit operator Config(string str)
    Parameters
    Type Name Description
    string str

    The string that contains a configuration.

    Returns
    Type Description
    Config

    A configuration based on the supplied string.

    Extension Methods

    ConfigExtensions.IsNullOrEmpty(Config)
    ConfigExtensions.SafeWithFallback(Config, Config)
    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET