Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injector as class member #546

Open
ValentinNikin opened this issue Mar 9, 2023 · 0 comments
Open

Injector as class member #546

ValentinNikin opened this issue Mar 9, 2023 · 0 comments

Comments

@ValentinNikin
Copy link

I have the configured injector, for example like this

auto injector = boost::di::make_injector(
            boost::di::bind<AgentsController>().in(boost::di::unique),
            boost::di::bind<AgentCommunicatorController>().in(boost::di::unique),
            boost::di::bind<IAgentsManager>.to<WorkflowManager>().in(boost::di::singleton),
            boost::di::bind<IAgentCommunicator>.to<WorkflowManager>().in(boost::di::singleton)
            );

I want to write Types Factory with this injector, something like this. But the question is what type should injector member be?

class TypesFactory {
public:
    template<typename T>
    T resolve() {
        return _injector.create<T>();
    }
private:
SomeTypeOfInjector _injector; <---- What type should SomeTypeOfInjector be?
}

Specifications

  • Version: boost::di 1.2.0
  • Platform: debian 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant