Skip to content

Legacy InjectionParameterValue #345

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

Closed
xcap2000 opened this issue Feb 18, 2019 · 7 comments
Closed

Legacy InjectionParameterValue #345

xcap2000 opened this issue Feb 18, 2019 · 7 comments

Comments

@xcap2000
Copy link

Description

InjectionParameterValue do not exist anymore. I have some legacy code that uses this class in order to allow resolving contructor arguments generically by order based on the following article:

https://mikaelkoskinen.net/post/unity-passing-constructor-parameters-to-resolve

I would like an alternative way of doing that on current version (5.x).

To Reproduce

Try using InjectionParameterValue.

@ENikS
Copy link
Contributor

ENikS commented Feb 18, 2019

It was renamed to ParameterValue

This is recommended way of using it:

// Constructor
Container.RegisterType<Service>(
    Invoke.Constructor(typeof(long), 
        Inject.Parameter(1)));

// Method
Container.RegisterType<Service>(
    Invoke.Method(nameof(Service.MethodOne), 
        Inject.Parameter(1)));

These are the available verbs you could use. Few examples how it could be used.

I am working on new documentation for all the changes...

@xcap2000
Copy link
Author

@ENikS Thank you for the fast reply. I will take a look and try to adapt the code using this new classes.

@ENikS ENikS closed this as completed Feb 18, 2019
@xcap2000
Copy link
Author

@ENikS I upgraded my code with your help and it worked like a charm. Thank you!

@emohammad
Copy link

@xcap2000 @ENikS do you guys have a solution on how you modified orderred parameters override?

@xcap2000
Copy link
Author

xcap2000 commented Oct 9, 2019

@ershad65 take a look at the following gist and tell me whether it helps you:

https://gist.github.com/xcap2000/2d264960cae55cf131edaa907a1a3eae

@emohammad
Copy link

Thanks @xcap2000. That helps

@xcap2000
Copy link
Author

@ershad65 you are welcome!

@ENikS ENikS transferred this issue from unitycontainer/unity Jun 4, 2021
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

3 participants