{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Extensions/issues/478","repository_url":"https://api.github.com/repos/aspnet/Extensions","labels_url":"https://api.github.com/repos/aspnet/Extensions/issues/478/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Extensions/issues/478/comments","events_url":"https://api.github.com/repos/aspnet/Extensions/issues/478/events","html_url":"https://github.com/aspnet/Extensions/issues/478","id":378628930,"node_id":"MDU6SXNzdWUzNzg2Mjg5MzA=","number":478,"title":"[DI] Pass the requested type to the implementation factory to enable dynamic scenarios when the type isn't known statically","user":{"login":"thomaslevesque","id":1864281,"node_id":"MDQ6VXNlcjE4NjQyODE=","avatar_url":"https://avatars3.githubusercontent.com/u/1864281?v=4","gravatar_id":"","url":"https://api.github.com/users/thomaslevesque","html_url":"https://github.com/thomaslevesque","followers_url":"https://api.github.com/users/thomaslevesque/followers","following_url":"https://api.github.com/users/thomaslevesque/following{/other_user}","gists_url":"https://api.github.com/users/thomaslevesque/gists{/gist_id}","starred_url":"https://api.github.com/users/thomaslevesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomaslevesque/subscriptions","organizations_url":"https://api.github.com/users/thomaslevesque/orgs","repos_url":"https://api.github.com/users/thomaslevesque/repos","events_url":"https://api.github.com/users/thomaslevesque/events{/privacy}","received_events_url":"https://api.github.com/users/thomaslevesque/received_events","type":"User","site_admin":false},"labels":[{"id":1104826625,"node_id":"MDU6TGFiZWwxMTA0ODI2NjI1","url":"https://api.github.com/repos/aspnet/Extensions/labels/area-dependencyinjection","name":"area-dependencyinjection","color":"5319e7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-11-08T08:39:27Z","updated_at":"2018-11-19T22:10:15Z","closed_at":"2018-11-14T18:10:05Z","author_association":"NONE","body":"### Is your feature request related to a problem? Please describe.\r\n\r\nI'm trying to enable lazy injection of services, i.e. if I registered a service for `IFoo`, I'd like to be able to inject a `Lazy<IFoo>` or `Func<IFoo>`. This is useful to solve circular dependency issues; [Unity](https://github.com/unitycontainer/unity) does this automatically. So I'd like to be able to do this:\r\n\r\n```csharp\r\nservices.AddTransient(typeof(Lazy<>), provider => \r\n{\r\n    ...\r\n});\r\n```\r\nHowever, in the factory delegate, I don't have access to the requested type, so I can't dynamically create a `Lazy<T>` of the appropriate type.\r\n\r\n### Describe the solution you'd like\r\n\r\nHaving overloads of `Add*` that accept a `Func<IServiceProvider, Type, object>` would solve this. However it looks like it would be non-trivial, since the `Func<IServiceProvider, object>` signature is used all the way down to the low-level implementation...\r\n\r\nAlternatively, implementing lazy injection like in Unity would solve my immediate problem, but would be less extensible.\r\n\r\n### Describe alternatives you've considered\r\n\r\nUsing a third-party container like Unity. But I'd rather keep using the built-in DI container.\r\n\r\n### Additional context\r\n\r\nN/A"},"comment":{"url":"https://api.github.com/repos/aspnet/Extensions/issues/comments/440059896","html_url":"https://github.com/aspnet/Extensions/issues/478#issuecomment-440059896","issue_url":"https://api.github.com/repos/aspnet/Extensions/issues/478","id":440059896,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDA1OTg5Ng==","user":{"login":"dotnetchris","id":116135,"node_id":"MDQ6VXNlcjExNjEzNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/116135?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnetchris","html_url":"https://github.com/dotnetchris","followers_url":"https://api.github.com/users/dotnetchris/followers","following_url":"https://api.github.com/users/dotnetchris/following{/other_user}","gists_url":"https://api.github.com/users/dotnetchris/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnetchris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnetchris/subscriptions","organizations_url":"https://api.github.com/users/dotnetchris/orgs","repos_url":"https://api.github.com/users/dotnetchris/repos","events_url":"https://api.github.com/users/dotnetchris/events{/privacy}","received_events_url":"https://api.github.com/users/dotnetchris/received_events","type":"User","site_admin":false},"created_at":"2018-11-19T22:10:15Z","updated_at":"2018-11-19T22:10:15Z","author_association":"NONE","body":"@pakrym then it should get slated that v+1 should break and just update the factory then."}}
{"actor":{"display_login":"dotnetchris"}}