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
| Improve this Doc 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
| Improve this Doc 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
| Improve this Doc 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 |
---|---|
Boolean |
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
| Improve this Doc 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, 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. |
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. |
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 |
---|---|
Nullable<Int64> | The long value defined in the specified path. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | This exception is thrown if the current node is undefined. |
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. |
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 = 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. |
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, 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. |
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. |
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. |
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. |
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. |
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. |
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, 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 |
|
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 |
---|---|
Boolean |
|
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
| Improve this Doc View SourceToString(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 |
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
| Improve this Doc View SourceAddition(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. |
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. |
Implicit(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. |