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

    | Improve this Doc View Source

    Config()

    Initializes a new instance of the Config class.

    Declaration
    public Config()
    | Improve this Doc 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.

    | Improve this Doc 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

    | Improve this Doc 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

    | Improve this Doc View Source

    Fallback

    The configuration used as a secondary source.

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

    IsEmpty

    Determines if this root node contains any values

    Declaration
    public virtual bool IsEmpty { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    Root

    The root node of this configuration section

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

    Substitutions

    An enumeration of substitutions values

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

    Methods

    | Improve this Doc 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.

    | Improve this Doc 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

    | Improve this Doc View Source

    GetBoolean(String, Boolean)

    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.

    Boolean default

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

    Returns
    Type Description
    Boolean

    The boolean value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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<Boolean>

    The list of boolean values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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.

    | Improve this Doc 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
    Nullable<Int64>

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc View Source

    GetByteSize(String, Nullable<Int64>)

    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.

    Nullable<Int64> def

    Default return value if none provided.

    Returns
    Type Description
    Nullable<Int64>

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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.

    | Improve this Doc 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 = 0M)
    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.

    | Improve this Doc 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.

    | Improve this Doc 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.

    | Improve this Doc 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.

    | Improve this Doc View Source

    GetFloat(String, Single)

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

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

    The path that contains the value to retrieve.

    Single default

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

    Returns
    Type Description
    Single

    The float value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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<Single>

    The list of float values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc View Source

    GetInt(String, Int32)

    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.

    Int32 default

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

    Returns
    Type Description
    Int32

    The integer value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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<Int32>

    The list of int values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc View Source

    GetLong(String, Int64)

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

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

    The path that contains the value to retrieve.

    Int64 default

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

    Returns
    Type Description
    Int64

    The long value defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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<Int64>

    The list of long values defined in the specified path.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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.

    | Improve this Doc 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.

    | Improve this Doc 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.

    | Improve this Doc View Source

    GetTimeSpan(String, Nullable<TimeSpan>, Boolean)

    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.

    Nullable<TimeSpan> default

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

    Boolean 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.

    | Improve this Doc 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.

    | Improve this Doc 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
    Boolean

    true if a value was found, false otherwise.

    Exceptions
    Type Condition
    InvalidOperationException

    This exception is thrown if the current node is undefined.

    | Improve this Doc 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()
    | Improve this Doc View Source

    ToString(Boolean)

    Converts the current configuration to a string

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

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

    Returns
    Type Description
    String

    TBD

    | Improve this Doc 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

    | Improve this Doc View Source

    Addition(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.

    | Improve this Doc View Source

    Addition(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.

    | Improve this Doc View Source

    Implicit(String to Config)

    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.SafeWithFallback(Config, Config)
    ConfigExtensions.IsNullOrEmpty(Config)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(Object)
    ObjectExtensions.IsDefaultForType<T>(T)
    In This Article
    • githubImprove this Doc
    • 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