Inherits: FileConfigReader
Description
The YamlConfigReader allows you to create a config reader that reads a configuration from a YAML file.
Configuration parameters
- path: path to the configuration file
- parameters: this entire section is used as template parameters
- …
Constructors
Creates a new instance of the config reader.
public YamlConfigReader(string path = null)
- path: string - (optional) path to the configuration file.
Instance methods
ReadConfig
Reads a configuration and parameterizes it with given values.
public override
ConfigParams ReadConfig(string correlationId, ConfigParams parameters)
- correlationId: string - (optional) transaction id to trace execution through a call chain.
- parameters: ConfigParams - values of the configuration parameters or null to skip parameterization.
- returns: ConfigParams - ConfigParams configuration.
ReadObject
Reads a configuration file, parameterizes its content and converts it into a YAML object.
public
object ReadObject(string correlationId, ConfigParams parameters)
- correlationId: string - (optional) transaction id to trace execution through a call chain.
- parameters: ConfigParams - values of the configuration parameters.
- returns: object - a YAML object with a configuration.
Static methods
ReadConfig
Reads a configuration from a file, parameterizes it with given values and returns a new ConfigParams object.
public static
ConfigParams ReadConfig(string correlationId, string path, ConfigParams parameters)
- correlationId: string - (optional) transaction id to trace the execution through a call chain.
- path: string - a path to configuration file.
- parameters: ConfigParams - values of the configuration parameters.
- returns: ConfigParams - ConfigParams configuration.
ReadObject
Reads a configuration file, parameterizes its content and converts it into a YAML object.
public static
object ReadObject(string correlationId, string path, ConfigParams parameters)
- correlationId: string - (optional) transaction id to trace the execution through a call chain.
- path: string - a path to configuration file.
- parameters: ConfigParams - values of the configuration parameters.
- returns: object - a YAML object containing a configuration.
Examples
key1: "{{KEY1_VALUE}}"
key2: "{{KEY2_VALUE}}"
var configReader = new YamlConfigReader("config.yml");
var parameters = ConfigParams.FromTuples("KEY1_VALUE", 123, "KEY2_VALUE", "ABC");
configReader.ReadConfig("123", parameters);