在运行时改变用户及其在WPF/Prism桌面应用程序中的权限的常见方法。

时间:2023-01-20 21:16:24

I have troubles with WPF desktop application based on Microsoft Prism Framework. The application has Logon dialog on startup that creates AuthenticationContext (User and Role) and runs Prism Bootstrapper (which creates ShellWindow and load Modules). Permissions are implemented using Markup Extensions and therefore parsed on view creation as I understand:

我在使用基于Microsoft Prism框架的WPF桌面应用程序时遇到了麻烦。应用程序在启动时具有登录对话框,该对话框创建AuthenticationContext(用户和角色)并运行Prism Bootstrapper(创建shell窗口和加载模块)。使用标记扩展实现权限,因此在创建视图时进行解析,如我所理解:

<MenuItem IsEnabled="{op:AuthToEnabled {x:Static a:ACL.CAN_CLOSE}}" ...>

Now I'm trying to add the abillity to change current user (and his permissions) at runtime. The possible ways of recreating entire bootstrapper or shell window does't work as expected and in generally look like hacks.

现在,我正在尝试添加在运行时更改当前用户(及其权限)的易用性。重新创建整个bootstrapper或shell窗口的可能方法并不像预期的那样工作,通常看起来像黑客。

Is there a common way or best practice to do such things (users, permissions itself and their changes) when using Prism or WPF in general?

在使用Prism或WPF时,是否有通用的方法或最佳实践来完成这些事情(用户、权限本身及其更改)?

1 个解决方案

#1


0  

I'm not positive, but I believe {x:Static } is only evaluated once and won't get re-evaluated even if your permissions change

我不是肯定的,但是我相信{x:Static}只被评估一次,即使您的权限改变了,也不会被重新评估

What about just restarting your application entirely when the user chooses to change logins?

当用户选择更改登录时,如何完全重新启动应用程序呢?

I do this with one of my applications which requires a restart when the login info changes:

我使用的一个应用程序需要在登录信息改变时重新启动:

Process.Start(Application.ResourceAssembly.Location);
Application.Current.Shutdown();

#1


0  

I'm not positive, but I believe {x:Static } is only evaluated once and won't get re-evaluated even if your permissions change

我不是肯定的,但是我相信{x:Static}只被评估一次,即使您的权限改变了,也不会被重新评估

What about just restarting your application entirely when the user chooses to change logins?

当用户选择更改登录时,如何完全重新启动应用程序呢?

I do this with one of my applications which requires a restart when the login info changes:

我使用的一个应用程序需要在登录信息改变时重新启动:

Process.Start(Application.ResourceAssembly.Location);
Application.Current.Shutdown();