Skip to content
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

@czema

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 });
}

Activity

  1. added this to the Backlog milestone on Aug 26, 2015
  2. divega commented on Aug 26, 2015

    @divega

    @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".

  3. HaoK commented on Feb 24, 2016

    @HaoK
    Member
  4. modified the milestones: 1.0.0-rc2, Backlog on Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions