ConfigDictionary.get

Get values from the configuration using config path notation.

  1. string get(string configPath, string defaultValue)
    class ConfigDictionary
    string
    get
    (
    string configPath
    ,
    string defaultValue = null
    )
  2. ConvertToType get(string configPath)
  3. ConvertToType get(string configPath, ConvertToType defaultValue)

Parameters

configPath string

Path to the wanted config value. The path is separated by dots, e.g. "server.public.hostname". Values from arrays can be selected by brackets, for example: "server[3].hostname.ports[0]". When the config is just a value, for example just a string, it can be fetched by just specifying "." as path. Although the path should be universally the same over all types of config files, some might not lend to this structure, and have a more specific way of retrieving data from the config. See the examples and specific config factories for more details.

defaultValue string

(Optional) Value to return when the given configPath is invalid. When not supplied a ConfigPathNotFoundException exception is thrown.

Return Value

Type: string

The value at the path in the configuration. To convert it use get!T().

Throws

ConfigReadException when something goes wrong reading the config. ConfigPathNotFoundException when the given path does not exist in the config.

Meta