You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
ConfigurationBinder provides ability for model to receive the IConfiguration. #274
Regarding ConfigurationBinder.cs, it would be nice if the IConfiguration object was provided to the model. Then we would be able to access data even if we didn't add a property for it. I propose, if the model has a IConfiguration property named "Configuration", then it's setter is invoked. The following would go after line 173 and line 198.
addMethod.Invoke(collection, new[] { item });
// If the model has a property named Configuration of type IConfiguration, pass the current configuration focus to the model.
var configProp = itemType.GetTypeInfo().GetDeclaredProperty("Configuration");
if (configProp != null && configProp.SetMethod != null && configProp.PropertyType == typeof(Microsoft.Framework.Configuration.IConfiguration)) {
configProp.SetMethod.Invoke(item, new object[] { configurationSection.Value });
}
@czema it would be interesting to know why you would want to do this and it doesn't seem to be a top priority given everything else that we need to do to ship, but we are not completely against it so we would consider a PR.
One detail to consider if you are planning to send a PR is that to be much more more consistent with how ConfigurationBinder works for other types,a property called "A" of type IConfiguration it should bind to configuration.GetSection("A"). Not sure if a property called "Configuration" should then be special cased as it is possible to have a section called "Configuration".
Activity
divega commentedon Aug 26, 2015
@czema it would be interesting to know why you would want to do this and it doesn't seem to be a top priority given everything else that we need to do to ship, but we are not completely against it so we would consider a PR.
One detail to consider if you are planning to send a PR is that to be much more more consistent with how ConfigurationBinder works for other types,a property called "A" of type IConfiguration it should bind to configuration.GetSection("A"). Not sure if a property called "Configuration" should then be special cased as it is possible to have a section called "Configuration".
HaoK commentedon Feb 24, 2016
3480095