This repository was archived by the owner on Dec 18, 2018. It is now read-only.
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
Closed
Description
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 });
}