{"action":"created","issue":{"url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/582","repository_url":"https://api.github.com/repos/simpleinjector/SimpleInjector","labels_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/582/labels{/name}","comments_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/582/comments","events_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/582/events","html_url":"https://github.com/simpleinjector/SimpleInjector/issues/582","id":339725866,"node_id":"MDU6SXNzdWUzMzk3MjU4NjY=","number":582,"title":"Registering dependencies from plugins","user":{"login":"hvidgaard","id":1030034,"node_id":"MDQ6VXNlcjEwMzAwMzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1030034?v=4","gravatar_id":"","url":"https://api.github.com/users/hvidgaard","html_url":"https://github.com/hvidgaard","followers_url":"https://api.github.com/users/hvidgaard/followers","following_url":"https://api.github.com/users/hvidgaard/following{/other_user}","gists_url":"https://api.github.com/users/hvidgaard/gists{/gist_id}","starred_url":"https://api.github.com/users/hvidgaard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvidgaard/subscriptions","organizations_url":"https://api.github.com/users/hvidgaard/orgs","repos_url":"https://api.github.com/users/hvidgaard/repos","events_url":"https://api.github.com/users/hvidgaard/events{/privacy}","received_events_url":"https://api.github.com/users/hvidgaard/received_events","type":"User","site_admin":false},"labels":[{"id":197522075,"node_id":"MDU6TGFiZWwxOTc1MjIwNzU=","url":"https://api.github.com/repos/simpleinjector/SimpleInjector/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-10T07:33:15Z","updated_at":"2018-07-10T08:32:02Z","closed_at":null,"author_association":"NONE","body":"I am creating a plugin based RestApi shell in Asp.Net Core. I've got that working by locating dlls and loading them. This works perfectly, but I would like to register dependencies for each plugin, with possible overlapping types. So in essence a \"nested container\", and when asp.net core is resolving a controller it should use the appropiate \"nested container\", and if resolution fails in that, try the parent container. Nested containers is not possible with SI, but I wonder if something else can achieve the same. I've been browsing the documentation and code, but I'm coming to the conclusion that it's probably beyond what I can figure out, if it is possible.\r\n\r\nThe gist of the idea of what I want to do in code is\r\n\r\nIn Startup.cs\r\n\r\n``` c#\r\nforeach (var plugin in plugins){\r\n    plugin.RegisterDepencencies(container);\r\n}\r\n```\r\nIn each implementation of plugin.\r\n``` c#\r\nRegisterDepencencies(Container cont){\r\n    cont.AddSingleton<MyInterface, MyImpl>(pluginAssemblyName);\r\n    ....\r\n    cont.Register<MyOtherInterface, MyOtherImpl>(pluginAssemblyName);\r\n}\r\n```\r\n\r\nSo whenever `SimpleInjectorControllerActivator` tries to resolve a controller instance, it will get the `AssemblyName` the controller lives in, and use that to resolve dependencies that is \"tagged\" with that particular `AssemblyName`. This of course also applies to all dependencies with the controller as the root.\r\n\r\nI was briefly considering using `RegisterConditional` but that would not work with dependencies of dependencies as far as I understand, as it's not possible to traverse the object graph with the `PredicateContext`.\r\n\r\nDo you have any pointers of where to focus my attention?"},"comment":{"url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/comments/403743722","html_url":"https://github.com/simpleinjector/SimpleInjector/issues/582#issuecomment-403743722","issue_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/582","id":403743722,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzc0MzcyMg==","user":{"login":"hvidgaard","id":1030034,"node_id":"MDQ6VXNlcjEwMzAwMzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1030034?v=4","gravatar_id":"","url":"https://api.github.com/users/hvidgaard","html_url":"https://github.com/hvidgaard","followers_url":"https://api.github.com/users/hvidgaard/followers","following_url":"https://api.github.com/users/hvidgaard/following{/other_user}","gists_url":"https://api.github.com/users/hvidgaard/gists{/gist_id}","starred_url":"https://api.github.com/users/hvidgaard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvidgaard/subscriptions","organizations_url":"https://api.github.com/users/hvidgaard/orgs","repos_url":"https://api.github.com/users/hvidgaard/repos","events_url":"https://api.github.com/users/hvidgaard/events{/privacy}","received_events_url":"https://api.github.com/users/hvidgaard/received_events","type":"User","site_admin":false},"created_at":"2018-07-10T08:32:02Z","updated_at":"2018-07-10T08:32:02Z","author_association":"NONE","body":"I was looking into that, but abandoned it because I would miss the ability to satisfy dependencies from the \"main\" container if the plugin hasn't have any registration for ILogger for instance. The way forward is probably to document a known few registrations that all containers get, logging for one, and then plugins should decorate them if they need to."}}
{"actor":{"display_login":"hvidgaard"}}