{"action":"created","issue":{"url":"https://api.github.com/repos/scaldi/scaldi/issues/61","labels_url":"https://api.github.com/repos/scaldi/scaldi/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/scaldi/scaldi/issues/61/comments","events_url":"https://api.github.com/repos/scaldi/scaldi/issues/61/events","html_url":"https://github.com/scaldi/scaldi/issues/61","id":115460215,"number":61,"title":"injecting from a class, not a type","user":{"login":"RonStein2000","id":81597,"avatar_url":"https://avatars.githubusercontent.com/u/81597?v=3","gravatar_id":"","url":"https://api.github.com/users/RonStein2000","html_url":"https://github.com/RonStein2000","followers_url":"https://api.github.com/users/RonStein2000/followers","following_url":"https://api.github.com/users/RonStein2000/following{/other_user}","gists_url":"https://api.github.com/users/RonStein2000/gists{/gist_id}","starred_url":"https://api.github.com/users/RonStein2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RonStein2000/subscriptions","organizations_url":"https://api.github.com/users/RonStein2000/orgs","repos_url":"https://api.github.com/users/RonStein2000/repos","events_url":"https://api.github.com/users/RonStein2000/events{/privacy}","received_events_url":"https://api.github.com/users/RonStein2000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-06T08:36:06Z","updated_at":"2015-11-26T02:11:07Z","closed_at":null,"body":"Is it possible to inject from a class at runtime, not a given type?. Use Case: I am getting the full class name from a remote site and want to create the corresponding instance by injection, not by reflection. All inject methods I found need a type with TypeTag, but it should be possible to just have the class and use the scaldi injection mechanism. I could not figure out, how to do it with the current code of scaldi."},"comment":{"url":"https://api.github.com/repos/scaldi/scaldi/issues/comments/159782560","html_url":"https://github.com/scaldi/scaldi/issues/61#issuecomment-159782560","issue_url":"https://api.github.com/repos/scaldi/scaldi/issues/61","id":159782560,"user":{"login":"OlegIlyenko","id":156569,"avatar_url":"https://avatars.githubusercontent.com/u/156569?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegIlyenko","html_url":"https://github.com/OlegIlyenko","followers_url":"https://api.github.com/users/OlegIlyenko/followers","following_url":"https://api.github.com/users/OlegIlyenko/following{/other_user}","gists_url":"https://api.github.com/users/OlegIlyenko/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegIlyenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegIlyenko/subscriptions","organizations_url":"https://api.github.com/users/OlegIlyenko/orgs","repos_url":"https://api.github.com/users/OlegIlyenko/repos","events_url":"https://api.github.com/users/OlegIlyenko/events{/privacy}","received_events_url":"https://api.github.com/users/OlegIlyenko/received_events","type":"User","site_admin":false},"created_at":"2015-11-26T02:11:07Z","updated_at":"2015-11-26T02:11:07Z","body":"Sorry for the late response. Sure, you can do it like this:\r\n\r\n```scala\r\nval clazz = classOf[SomeDynamicClass]\r\nval identifiers = TypeTagIdentifier(ReflectionHelper.classToType(clazz)) :: Nil\r\nval res = injectWithDefault[SomeParentOfDynamicClass](injector, noBindingFound(identifiers))(identifiers)\r\n```\r\n\r\nThis is a not very common use-case, so there is no dedicated `inject` method for this. On the other hand `injectWithDefault` (which is already available on `Injectable`) is pretty generic, so you can use it in conjunction with `noBindingFound`. You just need to provide it a custom list of identifies, like I have shown in the example above."}}