{"action":"created","comment":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/comments/168640045","pull_request_review_id":97041712,"id":168640045,"diff_hunk":"@@ -0,0 +1,49 @@\n+using System;\n+using System.Linq;\n+using System.Reflection;\n+\n+namespace Xamarin.Forms.Internals\n+{\n+\tpublic static class DependencyResolver\n+\t{\n+\t\tpublic delegate object ResolveDelegate(Type type, params object[] args);\n+\n+\t\tstatic ResolveDelegate Resolver { get; set; }\n+\n+\t\tpublic static void ResolveUsing(ResolveDelegate resolveDelegate)\n+\t\t{\n+\t\t\tResolver = resolveDelegate;\n+\t\t}\n+\n+\t\tpublic static void ResolveUsing(Func<Type, object> resolveFunc)\n+\t\t{\n+\t\t\tobject ResolveDelegate(Type type, object[] args) => resolveFunc.Invoke(type);\n+\t\t\tResolver = ResolveDelegate;\n+\t\t}\n+\n+\t\tinternal static object Resolve(Type type, params object[] args)\n+\t\t{\n+\t\t\treturn Resolver?.Invoke(type, args);\n+\t\t}\n+\n+\t\tinternal static object ForceResolve(Type type, params object[] args)\n+\t\t{\n+\t\t\tvar result = Resolve(type, args);\n+\n+\t\t\tif (result != null) return result;","path":"Xamarin.Forms.Core/DependencyResolver.cs","position":33,"original_position":33,"commit_id":"76391ff45eca96a9abfc2049b20165d39b933c0a","original_commit_id":"76391ff45eca96a9abfc2049b20165d39b933c0a","user":{"login":"kingces95","id":4120386,"avatar_url":"https://avatars1.githubusercontent.com/u/4120386?v=4","gravatar_id":"","url":"https://api.github.com/users/kingces95","html_url":"https://github.com/kingces95","followers_url":"https://api.github.com/users/kingces95/followers","following_url":"https://api.github.com/users/kingces95/following{/other_user}","gists_url":"https://api.github.com/users/kingces95/gists{/gist_id}","starred_url":"https://api.github.com/users/kingces95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingces95/subscriptions","organizations_url":"https://api.github.com/users/kingces95/orgs","repos_url":"https://api.github.com/users/kingces95/repos","events_url":"https://api.github.com/users/kingces95/events{/privacy}","received_events_url":"https://api.github.com/users/kingces95/received_events","type":"User","site_admin":false},"body":"Suggest we throw if Type is not assignable from the result. ","created_at":"2018-02-15T23:27:28Z","updated_at":"2018-02-15T23:54:11Z","html_url":"https://github.com/xamarin/Xamarin.Forms/pull/1870#discussion_r168640045","pull_request_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/comments/168640045"},"html":{"href":"https://github.com/xamarin/Xamarin.Forms/pull/1870#discussion_r168640045"},"pull_request":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870"}}},"pull_request":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870","id":168721345,"html_url":"https://github.com/xamarin/Xamarin.Forms/pull/1870","diff_url":"https://github.com/xamarin/Xamarin.Forms/pull/1870.diff","patch_url":"https://github.com/xamarin/Xamarin.Forms/pull/1870.patch","issue_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/1870","number":1870,"state":"open","locked":false,"title":"Allow users to specify resolution method for handlers, effects, and services","user":{"login":"hartez","id":538025,"avatar_url":"https://avatars0.githubusercontent.com/u/538025?v=4","gravatar_id":"","url":"https://api.github.com/users/hartez","html_url":"https://github.com/hartez","followers_url":"https://api.github.com/users/hartez/followers","following_url":"https://api.github.com/users/hartez/following{/other_user}","gists_url":"https://api.github.com/users/hartez/gists{/gist_id}","starred_url":"https://api.github.com/users/hartez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hartez/subscriptions","organizations_url":"https://api.github.com/users/hartez/orgs","repos_url":"https://api.github.com/users/hartez/repos","events_url":"https://api.github.com/users/hartez/events{/privacy}","received_events_url":"https://api.github.com/users/hartez/received_events","type":"User","site_admin":false},"body":"### Description of Change ###\r\n\r\nForms provides no option for users to construct and provide their own instances of handlers, effects, or services in a Forms application; instead, users must rely on `Activator.CreateInstance`. This greatly limits user control over the construction and lifetime of components.\r\n\r\nThis change provides a way for the user to inject their own dependency resolution method into Forms. When Forms needs a component instance of a particular type, the user's resolution method will be given the opportunity to provide the instance.\r\n\r\nIf no dependency resolution method is provided, Forms falls back to the previous behavior of creating the components as needed. If the dependency resolution method returns `null` for a requested component, Forms falls back to creating the components itself.\r\n\r\nWhen resolving an `Effect` or handler (e.g., a customer renderer), specifying the resolution method is sufficient. If the user wants to resolve a service from the `DependencyService`, they will have to use the new `Resolve<T>()` method. \r\n\r\n[A brief example of using this with an IoC container](https://gist.github.com/hartez/b8075b1bf05ff3494875ee5c9839157f)\r\n\r\n### Bugs Fixed ###\r\n\r\n- Fixes #1739 \r\n\r\n### API Changes ###\r\n\r\n#### Xamarin.Forms.Internals.DependencyResolver (new class)\r\n\r\n`public delegate object ResolveDelegate(Type type, params object[] args);`\r\n`public static void ResolveUsing(ResolveDelegate resolveDelegate)`\r\n`public static void ResolveUsing(Func<Type, object> resolveFunc)`\r\n\r\n#### Xamarin.Forms.DependencyService\r\n\r\n`public static T Resolve<T>(DependencyFetchTarget fallbackFetchTarget = DependencyFetchTarget.GlobalInstance)`\r\n\r\n### Behavioral Changes ###\r\n\r\nNone\r\n\r\n### PR Checklist ###\r\n\r\n- [x] Has tests (if omitted, state reason in description)\r\n- [x] Rebased on top of master at time of PR\r\n- [x] Changes adhere to coding standard\r\n- [x] Consolidate commits as makes sense\r\n","created_at":"2018-02-13T00:02:58Z","updated_at":"2018-02-15T23:54:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c63bf8814c68ecb5a45ce69a54473acf620fc9f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":816672203,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/F100","name":"F100","color":"e65bff","default":false},{"id":343860853,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/t/enhancement","name":"t/enhancement","color":"84b6eb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870/commits","review_comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870/comments","review_comment_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/1870/comments","statuses_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/statuses/76391ff45eca96a9abfc2049b20165d39b933c0a","head":{"label":"xamarin:use-di-container","ref":"use-di-container","sha":"76391ff45eca96a9abfc2049b20165d39b933c0a","user":{"login":"xamarin","id":790012,"avatar_url":"https://avatars0.githubusercontent.com/u/790012?v=4","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"repo":{"id":54213490,"name":"Xamarin.Forms","full_name":"xamarin/Xamarin.Forms","owner":{"login":"xamarin","id":790012,"avatar_url":"https://avatars0.githubusercontent.com/u/790012?v=4","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xamarin/Xamarin.Forms","description":"Xamarin.Forms official home","fork":false,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms","forks_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/forks","keys_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/teams","hooks_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/hooks","issue_events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/events{/number}","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/events","assignees_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/assignees{/user}","branches_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/branches{/branch}","tags_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/tags","blobs_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/statuses/{sha}","languages_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/languages","stargazers_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/stargazers","contributors_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/contributors","subscribers_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/subscribers","subscription_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/subscription","commits_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/contents/{+path}","compare_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/merges","archive_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/downloads","issues_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues{/number}","pulls_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls{/number}","milestones_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/milestones{/number}","notifications_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels{/name}","releases_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/releases{/id}","deployments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/deployments","created_at":"2016-03-18T15:52:03Z","updated_at":"2018-02-15T23:35:05Z","pushed_at":"2018-02-15T23:49:27Z","git_url":"git://github.com/xamarin/Xamarin.Forms.git","ssh_url":"git@github.com:xamarin/Xamarin.Forms.git","clone_url":"https://github.com/xamarin/Xamarin.Forms.git","svn_url":"https://github.com/xamarin/Xamarin.Forms","homepage":"https://xamarin.com/forms","size":38940,"stargazers_count":1906,"watchers_count":1906,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":822,"mirror_url":null,"archived":false,"open_issues_count":290,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":822,"open_issues":290,"watchers":1906,"default_branch":"master"}},"base":{"label":"xamarin:master","ref":"master","sha":"b96f65bdd9e7e931971338b122a8940e2a35ccc7","user":{"login":"xamarin","id":790012,"avatar_url":"https://avatars0.githubusercontent.com/u/790012?v=4","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"repo":{"id":54213490,"name":"Xamarin.Forms","full_name":"xamarin/Xamarin.Forms","owner":{"login":"xamarin","id":790012,"avatar_url":"https://avatars0.githubusercontent.com/u/790012?v=4","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xamarin/Xamarin.Forms","description":"Xamarin.Forms official home","fork":false,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms","forks_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/forks","keys_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/teams","hooks_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/hooks","issue_events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/events{/number}","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/events","assignees_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/assignees{/user}","branches_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/branches{/branch}","tags_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/tags","blobs_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/statuses/{sha}","languages_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/languages","stargazers_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/stargazers","contributors_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/contributors","subscribers_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/subscribers","subscription_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/subscription","commits_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/contents/{+path}","compare_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/merges","archive_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/downloads","issues_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues{/number}","pulls_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls{/number}","milestones_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/milestones{/number}","notifications_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels{/name}","releases_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/releases{/id}","deployments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/deployments","created_at":"2016-03-18T15:52:03Z","updated_at":"2018-02-15T23:35:05Z","pushed_at":"2018-02-15T23:49:27Z","git_url":"git://github.com/xamarin/Xamarin.Forms.git","ssh_url":"git@github.com:xamarin/Xamarin.Forms.git","clone_url":"https://github.com/xamarin/Xamarin.Forms.git","svn_url":"https://github.com/xamarin/Xamarin.Forms","homepage":"https://xamarin.com/forms","size":38940,"stargazers_count":1906,"watchers_count":1906,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":822,"mirror_url":null,"archived":false,"open_issues_count":290,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":822,"open_issues":290,"watchers":1906,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870"},"html":{"href":"https://github.com/xamarin/Xamarin.Forms/pull/1870"},"issue":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/1870"},"comments":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/1870/comments"},"review_comments":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870/comments"},"review_comment":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/1870/commits"},"statuses":{"href":"https://api.github.com/repos/xamarin/Xamarin.Forms/statuses/76391ff45eca96a9abfc2049b20165d39b933c0a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kingces95"}}