-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make the Resolve method public #31
Comments
@matt-goldman Actually it's quite straightforward. No parametersTo inject a popup with no parameters, I just need the Resvole method made public - await MopupService.Instance.PushAsync(Resolver.Resolve<AddPopup>()); With parametersTo inject a popup with parameters, just need the
await MopupService.Instance.PushAsync((PopupPage)NavigationExtensions.ResolvePage<AddPopup>(123)); Might need to think of a way to avoid the cast though |
Sorry for the delay. I want to keep this private to avoid service locator behavior. I think what I'll do here is release a separate package, |
@matt-goldman thanks, ye that will work fine :) I did have to change something in the resolve method as I was getting a weird exception, I will work out the changes I made sometime next week |
@matt-goldman this was the exception i mentioned above - It comes from this line - https://github.com/matt-goldman/Maui.Plugins.PageResolver/blob/88b83a2c16495f00afb0eb45dd5ffd65975205b5/src/Maui.Plugins.PageResolver/NavigationExtensions.cs#L88C8-L88C105 Changing the code from - var resolvedPage = ActivatorUtilities.CreateInstance<T>(serviceProvider, typeof(T), parameters);
return resolvedPage; To - return ActivatorUtilities.CreateInstance<T>(serviceProvider, parameters); Im not too familiar with the internal DI methods so not sure what the difference is, but after I made that change it all started to work. The code that caused the exception is pretty straightforward - |
Hi @IeuanWalker, sorry this has taken so long! I've got #39 open which should give you what you need. Slight variation on yours, it's an extension on I've published the nuget already, when you get the chance please test and let me know what you think. I'll update the wiki soon too. |
@matt-goldman i cloned your repo to update my local changes to make sure everything worked before switching to the NuGets, and all worked great. So I removed the local copy and installed the NuGets instead - But am now getting source generator errors - And far as im aware im not using your SG stuff -
|
Hey @IeuanWalker, thanks for testing this. Sorry this has happened - this is because I tried to improve the convenience of auto dependencies. It runs whether or not you call it (it has to in order to generate the That will need to be in a future version though, if I do it now it will be a breaking change and I think that needs some advance warning. In the meantime I'll release a version that does the opposite - I'll give you an interface and attribute (you can pick which one you want to use) that marks it for exclusion, and this will terminate the source generator. Immediate version: public static class MauiProgram : INoAutoDependencies
// or, pick whichever
[NoAutoDependencies]
public static class MauiProgram future: public static class MauiProgram : IUseAutoDependencies
// or, pick whichever
[UseAutoDependencies]
public static class MauiProgram I'll push the immediate update today and open a discussion for the future version. Sorry I know it's not ideal, but hopefully that works for you. |
Thanks @matt-goldman, a DataAnnotation will be fine :) |
Done in #40. v2.5.2 processing with Nuget now, should be available any minute. I've tested and it works for me, please let me know how you go. Thanks! 🙂 |
@matt-goldman thanks, that all works with the NuGets now :) |
Is your feature request related to a problem? Please describe.
I'd like to be able to use the
Resolve
method directly in order to extend the functionality for things other than INavigation.Describe the solution you'd like
Make certain methods public, or possibly even create a separate project for Mopups support and give it access to internal methods of this project.
Additional context
We use Mopups for our popups in our app. After a quick fiddle, I was able to get PageResolver to work with Mopups.
For example, I registered the popup and ViewModel like any other page -
I then made the
Resolve<T>
public, and was able to get this to work -Obviously, I'd need to do quite a bit more work to get it to work with parameters.
Just seeing if you're open to something like this?
The text was updated successfully, but these errors were encountered: