{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Options/pulls/comments/29360132","id":29360132,"diff_hunk":"@@ -0,0 +1,241 @@\n+﻿// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Reflection;\n+using Microsoft.Framework.ConfigurationModel;\n+using Microsoft.Framework.Internal;\n+\n+namespace Microsoft.Framework.OptionsModel\n+{\n+    public static class ConfigurationBinder\n+    {\n+        public static TOptions Bind<TOptions>(IConfiguration configuration) where TOptions : new()\n+        {\n+            var model = new TOptions();\n+            Bind(model, configuration);\n+            return model;\n+        }\n+\n+        public static void Bind(object model, IConfiguration configuration)\n+        {\n+            if (model == null)\n+            {\n+                return;\n+            }\n+\n+            BindObjectProperties(model, configuration);\n+        }\n+\n+        private static void BindObjectProperties(object obj, IConfiguration configuration)\n+        {\n+            foreach (var property in GetAllProperties(obj.GetType().GetTypeInfo()))\n+            {\n+                BindProperty(property, obj, configuration);\n+            }\n+        }\n+\n+        private static void BindProperty(PropertyInfo property, object propertyOwner, IConfiguration configuration)\n+        {\n+            configuration = configuration.GetSubKey(property.Name);\n+\n+            if (property.GetMethod == null || !property.GetMethod.IsPublic)\n+            {\n+                // We don't support set only properties\n+                return;\n+            }\n+\n+            var propertyValue = property.GetValue(propertyOwner);\n+            var hasPublicSetter = property.SetMethod != null && property.SetMethod.IsPublic;\n+\n+            if (propertyValue == null && !hasPublicSetter)\n+            {\n+                // Property doesn't have a value and we cannot set it so there is no\n+                // point in going further down the graph\n+                return;\n+            }\n+\n+            propertyValue = BindType(property.PropertyType, propertyValue, configuration);\n+\n+            if (propertyValue != null && hasPublicSetter)\n+            {\n+                property.SetValue(propertyOwner, propertyValue);\n+            }\n+        }\n+\n+\n+        private static object BindType(Type type, object typeInstance, IConfiguration configuration)\n+        {\n+            var configValue = configuration.Get(null);","path":"src/Microsoft.Framework.OptionsModel/ConfigurationBinder.cs","position":71,"original_position":71,"commit_id":"125231e16018e765e0c875ceb3f55b8bc9ed32ab","original_commit_id":"125231e16018e765e0c875ceb3f55b8bc9ed32ab","user":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"body":"Gets the value of that configuration node. Currently, that's the only way to get the value","created_at":"2015-04-29T17:39:42Z","updated_at":"2015-04-29T17:39:42Z","html_url":"https://github.com/aspnet/Options/pull/59#discussion_r29360132","pull_request_url":"https://api.github.com/repos/aspnet/Options/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Options/pulls/comments/29360132"},"html":{"href":"https://github.com/aspnet/Options/pull/59#discussion_r29360132"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Options/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Options/pulls/59","id":34192714,"html_url":"https://github.com/aspnet/Options/pull/59","diff_url":"https://github.com/aspnet/Options/pull/59.diff","patch_url":"https://github.com/aspnet/Options/pull/59.patch","issue_url":"https://api.github.com/repos/aspnet/Options/issues/59","number":59,"state":"open","locked":false,"title":"List and Dictionary binding","user":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"body":"Fixes: https://github.com/aspnet/Options/issues/56\r\n\r\n- Support for binding to lists\r\n- Support for binding to dictionary\r\n\r\nPlease review: @lodejard @HaoK @glennc ","created_at":"2015-04-27T17:48:49Z","updated_at":"2015-04-29T17:39:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"442a0ef234b37916736d92cc33d16140e7d4f19b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Options/pulls/59/commits","review_comments_url":"https://api.github.com/repos/aspnet/Options/pulls/59/comments","review_comment_url":"https://api.github.com/repos/aspnet/Options/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Options/issues/59/comments","statuses_url":"https://api.github.com/repos/aspnet/Options/statuses/125231e16018e765e0c875ceb3f55b8bc9ed32ab","head":{"label":"aspnet:victorhu/arrays","ref":"victorhu/arrays","sha":"125231e16018e765e0c875ceb3f55b8bc9ed32ab","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":20275431,"name":"Options","full_name":"aspnet/Options","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Options","description":"A framework for accessing and configuring POCO settings.","fork":false,"url":"https://api.github.com/repos/aspnet/Options","forks_url":"https://api.github.com/repos/aspnet/Options/forks","keys_url":"https://api.github.com/repos/aspnet/Options/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Options/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Options/teams","hooks_url":"https://api.github.com/repos/aspnet/Options/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Options/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Options/events","assignees_url":"https://api.github.com/repos/aspnet/Options/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Options/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Options/tags","blobs_url":"https://api.github.com/repos/aspnet/Options/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Options/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Options/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Options/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Options/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Options/languages","stargazers_url":"https://api.github.com/repos/aspnet/Options/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Options/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Options/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Options/subscription","commits_url":"https://api.github.com/repos/aspnet/Options/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Options/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Options/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Options/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Options/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Options/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Options/merges","archive_url":"https://api.github.com/repos/aspnet/Options/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Options/downloads","issues_url":"https://api.github.com/repos/aspnet/Options/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Options/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Options/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Options/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Options/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Options/releases{/id}","created_at":"2014-05-28T23:13:36Z","updated_at":"2015-04-22T17:47:15Z","pushed_at":"2015-04-29T17:29:15Z","git_url":"git://github.com/aspnet/Options.git","ssh_url":"git@github.com:aspnet/Options.git","clone_url":"https://github.com/aspnet/Options.git","svn_url":"https://github.com/aspnet/Options","homepage":"","size":1008,"stargazers_count":34,"watchers_count":34,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":13,"forks":9,"open_issues":13,"watchers":34,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"b51938a508b86973f9e85402a4cc70faffe0d178","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":20275431,"name":"Options","full_name":"aspnet/Options","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Options","description":"A framework for accessing and configuring POCO settings.","fork":false,"url":"https://api.github.com/repos/aspnet/Options","forks_url":"https://api.github.com/repos/aspnet/Options/forks","keys_url":"https://api.github.com/repos/aspnet/Options/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Options/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Options/teams","hooks_url":"https://api.github.com/repos/aspnet/Options/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Options/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Options/events","assignees_url":"https://api.github.com/repos/aspnet/Options/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Options/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Options/tags","blobs_url":"https://api.github.com/repos/aspnet/Options/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Options/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Options/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Options/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Options/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Options/languages","stargazers_url":"https://api.github.com/repos/aspnet/Options/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Options/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Options/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Options/subscription","commits_url":"https://api.github.com/repos/aspnet/Options/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Options/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Options/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Options/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Options/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Options/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Options/merges","archive_url":"https://api.github.com/repos/aspnet/Options/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Options/downloads","issues_url":"https://api.github.com/repos/aspnet/Options/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Options/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Options/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Options/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Options/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Options/releases{/id}","created_at":"2014-05-28T23:13:36Z","updated_at":"2015-04-22T17:47:15Z","pushed_at":"2015-04-29T17:29:15Z","git_url":"git://github.com/aspnet/Options.git","ssh_url":"git@github.com:aspnet/Options.git","clone_url":"https://github.com/aspnet/Options.git","svn_url":"https://github.com/aspnet/Options","homepage":"","size":1008,"stargazers_count":34,"watchers_count":34,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":13,"forks":9,"open_issues":13,"watchers":34,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Options/pulls/59"},"html":{"href":"https://github.com/aspnet/Options/pull/59"},"issue":{"href":"https://api.github.com/repos/aspnet/Options/issues/59"},"comments":{"href":"https://api.github.com/repos/aspnet/Options/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Options/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Options/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Options/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Options/statuses/125231e16018e765e0c875ceb3f55b8bc9ed32ab"}}}}