{"action":"created","issue":{"url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/32","repository_url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection","labels_url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/32/comments","events_url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/32/events","html_url":"https://github.com/unitycontainer/microsoft-dependency-injection/issues/32","id":390829336,"node_id":"MDU6SXNzdWUzOTA4MjkzMzY=","number":32,"title":"Add Support for Custom Resolution","user":{"login":"spasarto","id":4016573,"node_id":"MDQ6VXNlcjQwMTY1NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/4016573?v=4","gravatar_id":"","url":"https://api.github.com/users/spasarto","html_url":"https://github.com/spasarto","followers_url":"https://api.github.com/users/spasarto/followers","following_url":"https://api.github.com/users/spasarto/following{/other_user}","gists_url":"https://api.github.com/users/spasarto/gists{/gist_id}","starred_url":"https://api.github.com/users/spasarto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spasarto/subscriptions","organizations_url":"https://api.github.com/users/spasarto/orgs","repos_url":"https://api.github.com/users/spasarto/repos","events_url":"https://api.github.com/users/spasarto/events{/privacy}","received_events_url":"https://api.github.com/users/spasarto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-13T19:40:32Z","updated_at":"2018-12-13T21:16:48Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I would like to discuss the possibility of adding the ability to customize type resolution. As of right now, the current implementation of Resolve looks like this:\r\n\r\n        public object GetService(Type serviceType)\r\n        {\r\n            try\r\n            {\r\n                return _container.Resolve(serviceType);\r\n            }\r\n            catch  { /* Ignore */}\r\n\r\n            return null;\r\n       }\r\n\r\nThis works for simple cases, but it doesn't allow us to pass in additional values into the resolution - names or resolver overrides. It may also be nice to respond to resolution errors. For reference, here is the current Unity Resolve method:\r\n\r\n     public object Resolve(Type typeToBuild, string nameToBuild, params ResolverOverride[] resolverOverrides);\r\n\r\n\r\nOne possibility is to add support for `IOptions<ResolutionOptions>`, where `ResolutionOptions `looks like this:\r\n\r\n     public class ResolutionOptions\r\n     {\r\n          public Fun<IUnityContainer, Type, object> Resolve {get;set;}\r\n     }"},"comment":{"url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/comments/447123581","html_url":"https://github.com/unitycontainer/microsoft-dependency-injection/issues/32#issuecomment-447123581","issue_url":"https://api.github.com/repos/unitycontainer/microsoft-dependency-injection/issues/32","id":447123581,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzEyMzU4MQ==","user":{"login":"spasarto","id":4016573,"node_id":"MDQ6VXNlcjQwMTY1NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/4016573?v=4","gravatar_id":"","url":"https://api.github.com/users/spasarto","html_url":"https://github.com/spasarto","followers_url":"https://api.github.com/users/spasarto/followers","following_url":"https://api.github.com/users/spasarto/following{/other_user}","gists_url":"https://api.github.com/users/spasarto/gists{/gist_id}","starred_url":"https://api.github.com/users/spasarto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spasarto/subscriptions","organizations_url":"https://api.github.com/users/spasarto/orgs","repos_url":"https://api.github.com/users/spasarto/repos","events_url":"https://api.github.com/users/spasarto/events{/privacy}","received_events_url":"https://api.github.com/users/spasarto/received_events","type":"User","site_admin":false},"created_at":"2018-12-13T21:16:48Z","updated_at":"2018-12-13T21:16:48Z","author_association":"CONTRIBUTOR","body":"Thanks for the reply.\r\n\r\nThe first two cases address registration overrides, which is a different scenario. The third option requires me to do the resolution, which doesn't work when code I don't control is performing the resolution.\r\n\r\nFor example, let's say I have a web project, and I register my types normally. However for certain web requests, I want to resolve a different set of dependencies (ie, dryrun/beta implementations/regional cases, etc). Because I don't have access to type resolution, I am stuck resolving whatever I registered. This pushes the burden to all of my implementations to know if they need to handle this other case. I would prefer to pass in a `ResolverOverride` to unity's resolution that informs the container to resolve the second set of dependencies, when appropriate.\r\n\r\nHopefully that better explains the need for this customization."}}
{"actor":{"display_login":"spasarto"}}