A helper package for easy configuration
Add ManyConfig
attribute to your configuration properties and specify DefaultValue for them.
public class ElasticConfig
{
[ManyConfig(Key = "elasticsearch-connection-string",
DefaultValue = "http://localhost:9200")]
public string ConnectionString { get; set; }
[ManyConfig(Key = "elasticsearch-index",
DefaultValue = "comments")]
public string IndexName { get; set; }
}
In app.config
you can override your DefaultValue property by Key
field:
<appSettings>
<add key="elasticsearch-connection-string" value="http://127.0.0.1:9200" />
</appSettings>
Then you can use configuration:
ElasticConfig elasticConfiguration = ConfigHandler.Get<ElasticConfig>();
- Covering by test