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

From Version 2.x to 3.0 #90

Closed
JAzevedoDev opened this issue Jan 17, 2020 · 6 comments
Closed

From Version 2.x to 3.0 #90

JAzevedoDev opened this issue Jan 17, 2020 · 6 comments

Comments

@JAzevedoDev
Copy link

JAzevedoDev commented Jan 17, 2020

Hello
In version 2.x

Public static void OpenPage(string pageName, dynamic rec,IModalService modalService, Action<string, dynamic> action, string group = "std")
        {
                string MyPageName = $"MyProject.Pages.{group}.Pages." + pageName;
                Type MYTYPE = Type.GetType(MyPageName);
                ModalParameters ModalParams = new ModalParameters();
                ModalParams.Add("RecRef", rec);
                ModalParams.Add("executeOnValidate", action);
                ModalParams.Add("isModal", true);
                modalService.Show(pageName, MYTYPE, ModalParams);
        }

And in 3.0 this dont work anymore because i need to to include Show<MyProject.Pages.std.Pages.MYPAGE> but i cant use the MYTYPE like this: modal.Show(...)

Public static void OpenPage(string pageName, dynamic rec,IModalService modalService, Action<string, dynamic> action, string group = "std")
        {
                string MyPageName = $"MyProject.Pages.{group}.Pages." + pageName;
                Type MYTYPE = Type.GetType(MyPageName);
                ModalParameters ModalParams = new ModalParameters();
                ModalParams.Add("RecRef", rec);
                ModalParams.Add("executeOnValidate", action);
                ModalParams.Add("isModal", true);
                modalService.Show<MYTYPE>(pageName, ModalParams);
        }
@larsk2009
Copy link
Collaborator

You are right that you cannot do what you did in v2.x anymore in v3.x unless I am missing something. The v3.x function is using generics. The compiler needs to be able to infer the type at compile-time, which is not possible when using a variable for the type.

I can see this was changed by @chrissainty in this commit. I think Show() was chosen above the old Show() function because with the generic function you can easily constrain the type so only components can be passed to Show and not all types. But Chris can probably explain this better than me.

Finally, I haven't tested this but I think you might be able to do what you want using reflection. See this link for a starting point. Like I said, I haven't tested that at all so it might not work in this specific case.

@chrissainty
Copy link
Member

@joseazevedo I've added some new overloads to Show which allow the old type usage. It will be in the next release.

@JAzevedoDev
Copy link
Author

JAzevedoDev commented Jan 20, 2020 via email

@kiwiingenuity
Copy link

Chris,
Really appreciate the new show overloads!
Can you also add these overloads to IModalService please?

@chrissainty
Copy link
Member

@kiwiingenuity I've just pushed an update to NuGet. Let me know if you have any problems.

@JAzevedoDev
Copy link
Author

JAzevedoDev commented Feb 10, 2020 via email

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

4 participants