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

NavigationParameters: Not possible to specify parent type as generic parameter T #1008

Closed
michaelmairegger opened this issue Mar 31, 2017 · 3 comments

Comments

@michaelmairegger
Copy link
Contributor

michaelmairegger commented Mar 31, 2017

Package info

  • Prism version: newest public version

Repro steps

If I add a parameter of any custom type and want to retrieve the parameter by its parent type then an exception is thrown. This exception indicates that the type must implement IConvertible in order to be able to return a value. This is incorrect. Since the object added to NavigationParameters is an inheritor of the type I passed as generic type parameter there is no need to inherit from IConvertible. The value can immediately be returned

Error

public class Test : ICustomInterface{}

NavigationParameters np = new NavigationParameters ();
np.Add("Test", new Test());

np.GetValue<object>(); //this line is not possible
np.GetValue<ICustomInterface>(); //this line is not possible

Both lines results in:

System.InvalidCastException: Object must implement IConvertible

@brianlagunas
Copy link
Member

Can you provide an example? I would hate to include a reflection call every time a command is executed. This will really suck for mobile platforms.

@michaelmairegger
Copy link
Contributor Author

@brianlagunas I have updated the initial post. Unfortunately the <> brackets were not rendered in the final output.
The reflection call is not inside the commands. Should only be called when accessing NavigationParameters

@lock
Copy link

lock bot commented Jan 30, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants