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.
Inherited Members
Namespace: Akka.Configuration
Assembly: Akka.dll
Syntax
public class Config
Constructors
| Edit this page View SourceConfig()
Initializes a new instance of the Config class.
Declaration
public Config()
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 |
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 |
Fields
| Edit this page View SourceEmpty
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 SourceFallback
The configuration used as a secondary source.
Declaration
public Config Fallback { get; }
Property Value
Type | Description |
---|---|
Config |
IsEmpty
Determines if this root node contains any values
Declaration
public virtual bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
Root
The root node of this configuration section
Declaration
public virtual HoconValue Root { get; }
Property Value
Type | Description |
---|---|
HoconValue |
Substitutions
An enumeration of substitutions values
Declaration
public IEnumerable<HoconSubstitution> Substitutions { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<HoconSubstitution> |
Methods
| Edit this page View SourceAsEnumerable()
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. |
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 |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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 |
|
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. |
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 |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | This exception is thrown if the current node is undefined. |
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 |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | This exception is thrown if the current node is undefined. |
ToString()
Converts the current configuration to a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string containing the current configuration. |
Overrides
| Edit this page View SourceToString(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 |
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 |
Operators
| Edit this page View Sourceoperator +(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. |
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. |
implicit operator Config(string)
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. |