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

[feature request] have more control over dependency overrides #165

Open
kicsiede opened this issue Apr 26, 2024 · 3 comments
Open

[feature request] have more control over dependency overrides #165

kicsiede opened this issue Apr 26, 2024 · 3 comments
Labels

Comments

@kicsiede
Copy link

It would be beneficial to have more precise control over passing dependency overrides, along with support for named bindings. Currently, our approach is as follows:

container.Resolve<Service>([ instance1, instance2... ])

In this setup, type overrides are automatically resolved based on their type and the classes/interfaces they implement, as far as I know.

I propose introducing a wrapper that the resolver could use to extract specific additional information, like this:

container.Resolve<Service>([ Arg<IExactType1>(instance1), Arg<IExactType2>("name", instance2)... ])

This approach would enable us to specify dependencies more explicitly and manage named bindings more effectively.

@z4kn4fein
Copy link
Owner

z4kn4fein commented May 29, 2024

Hi @kicsiede, thank you for the suggestion, and sorry for the late reply! I'll look at both issues soon when I have more free time.

@z4kn4fein
Copy link
Owner

Hi @kicsiede, I've released v5.16.0, which allows dependency overrides to be expressed with a new Override type.

var service = container.Resolve<IService>([ Override.Of(instance, "name") ]);

Could you please check that it works for your use case? Thanks!

Copy link

This issue is marked stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the Stale label Nov 20, 2024
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