基于用户权限的 MEF 组件

发布于 2024-12-06 05:54:33 字数 345 浏览 1 评论 0原文

几个月前,我迈出了迈向 MEF 的第一步,到目前为止一切似乎都还不错。我想做的是在我的实际应用程序中使用 MEF 并加载,或者我们可以说基于经过身份验证的用户权限显示 UI 组件。我正在为诊所开发患者管理系统,我想实现根据用户类型显示 MEF 组成的 UI 组件的场景。例如,如果经过身份验证的用户是医生,我想显示特定组件并隐藏其他组件。

我想要实现的目标是

ISystemComponent ,它具有一些属性和方法,以便管理可以控制每个用户访问级别,并根据数据库记录 MEF 组成的控件将显示给最终用户。我还考虑在导出组件时使用元数据接口,那么使用它如何才能获得所需的结果?

任何正确的方向将不胜感激

I did my first steps toward MEF few month ago and everything seemed to be okay till now. What I want to do is to use MEF in now of my real applications and load or we can say display UI components based on authenticated users permissions. I am developing patient management system for clinic and I want to implement scenario where MEF composed UI components are displayed based on user type. for example if authenticated user is doctor I want to show particular components and hid others.

What I am trying to achieve is something like

ISystemComponent which has some properties and methods so administration can control each user access level and based on DB records MEF composed controls will be displayed to the end-user. I also think of using MetaData interface while exporting components so using this how can I get the desired result?

any right direction will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

戴着白色围巾的女孩 2024-12-13 05:54:33

I did this by using an metadata attribute for a module ID and a table that has the permissions .

Do a ImportMany on the interface then filter it based on the metadata attribute using reflection and compare to the permissions in the table.

This blog post describes all the MEF involved.

http://blogs.microsoft.co.il/blogs/bnaya/archive/2010/01/20/mef-for-beginner-metadata-part-8.aspx

Other Links..

http://blogs.microsoft.co.il/blogs/bnaya/archive/2010/01/09/mef-for-beginner-toc.aspx

http://mef.codeplex.com/wikipage?title=Exports%20and%20Metadata&referringTitle=Guide

MEF Plugins with Security and Profiles Efficency

MEF with ImportMany and ExportMetadata

This will show how to import from xaml

http://blogs.microsoft.co.il/blogs/bnaya/archive/2010/03/20/mef-for-beginner-import-from-xaml-part-11.aspx

天涯离梦残月幽梦 2024-12-13 05:54:33

此处一文详细介绍了如何使用 AOP 将安全问题注入 MEF。这可能是实现此目的的一种方法 - 我还没有在 MEF 中找到任何可以在其他地方实现此类功能的内容。

The article here details using AOP to inject security concerns into MEF. This could be one way of doing this - I havent' found anything in MEF that would allow this sort of functionality elsewhere.

寂寞笑我太脆弱 2024-12-13 05:54:33

我认为 PRISM 完全可以实现您所描述的功能。请查看这篇代码项目文章。您可以创建多个模块目录(根据用户权限),并按照描述从 XML 动态加载目录 这里

var catalog = ModuleCatalog.CreateFromXaml(new Uri("catalog.xaml", 
                                                 UriKind.Relative));

I think PRISM can do exactly what you've described. Take a look at this Code Project article. You can create several module catalogs (according to user permissions), and load catalog dynamically from XML as described Here:

var catalog = ModuleCatalog.CreateFromXaml(new Uri("catalog.xaml", 
                                                 UriKind.Relative));
冷︶言冷语的世界 2024-12-13 05:54:33

我使用 Cinch 和将控件映射到的后端 SQL 表在 WPF / MVVM 中实现了此功能角色和查看权限。这允许您通过视图模型控制权限并随时更改可见性。

Cinch 协助完成 MVVM 的一些苦差事,同时允许您通过 MeffedMVVM 或 Prism。

I implemented this in WPF / MVVM using Cinch and backend SQL tables that mapped controls to roles and view permissions. This allows you to control permissions through the viewmodel and change visibility at any point.

Cinch assists with some of the drudgery of MVVM while allowing you to leverage MEF through MeffedMVVM or Prism.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文