Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config overloads to pass both a IConfigSection and IConfiguration #148

Closed
tsimbalar opened this issue Oct 15, 2018 · 2 comments · Fixed by #163
Closed

Add config overloads to pass both a IConfigSection and IConfiguration #148

tsimbalar opened this issue Oct 15, 2018 · 2 comments · Fixed by #163

Comments

@tsimbalar
Copy link
Member

Right now, when calling ReadFrom.ConfigSection(IConfigurationSection configSection), the ConfigurationReader does not have access to the global IConfiguration object, so it cannot access the configuration out of the given section. That makes it impossible to access, say, the ConnectionStrings ... .

In PR #144 we added a check to throw an exception when calling a config method that expects an IConfiguration from the ReadFrom.ConfigSection overload so that users don't shoot themselves in the foot.

We should probably mark ConfigurationSection(this LoggerSettingsConfiguration settingConfiguration /*, ...*/) methods as obsolete and instead provide new overloads like

ReadFrom.ConfigurationSection(
  this LoggerSettingsConfiguration settingConfiguration, 
  IConfiguration configuration, 
  string sectionName /*, ...*/)

this would store the global IConfiguration object and look for a section with a given name within.

Does that seem to make sense ?

See #143 for more details

@MV10
Copy link
Contributor

MV10 commented Oct 16, 2018

Haven't had time to look at the code yet, but based on the issue that brought up the problem, I assume the exception is only thrown if the parameter doesn't have a default value?

@tsimbalar
Copy link
Member Author

@MV10 good catch ! I had missed that case.

Just created a PR to fix it : #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants