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

How to use Factory and inject value in constructor in IOC? #36

Closed
jkour opened this issue Jun 3, 2020 · 3 comments
Closed

How to use Factory and inject value in constructor in IOC? #36

jkour opened this issue Jun 3, 2020 · 3 comments
Labels

Comments

@jkour
Copy link
Contributor

jkour commented Jun 3, 2020

Hi,
I am looking at the IOC and I want to do the following:

Say I have TBase class and TClassA and TClassB inheriting from TBase.

Now I want a factory to produce either classA or classB. Can I use Abstract Factory for this?

Thanks

@exilon
Copy link
Owner

exilon commented Jun 3, 2020

container.AbstractFactory(TBase) creates a TBase object and returns as TBaseA
container.AbstractFactory creates a TBaseA object and returns as TBaseA object
Both examples will resolve constructor injections of TBaseA

@jkour
Copy link
Contributor Author

jkour commented Jun 3, 2020

Thanks for the explanation.

I alse see the IOC holds an IOCInjector but there is no way to pass it to the IOC. How is this meant to be used?
I also see that when you resolve the objects/classes you consider params in constructors/methods but again how do you inject custom params?

@exilon
Copy link
Owner

exilon commented May 1, 2023

Closing this issue as it has been inactive for an extended period of time and there has been no recent activity. If this issue is still relevant, please feel free to reopen it with updated information.

@exilon exilon closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants