User Permission Based MEF Components

I took the first steps towards MEF a few months ago, and so far everything was in order. I want to use MEF in my real applications and downloads, or we can say that the user interface components are based on the allowed user rights. I am developing a patient management system for a clinic, and I want to implement a scenario in which the MI components that make up the user interface are displayed based on the type of user. for example, if the authenticated user is a doctor, I want to show specific components and hide others.

What I'm trying to achieve is something like

ISystemComponent , which has some properties and methods, so administration can control each level of user access and based on database records. The controls created by MEF will be displayed to the end user. I also think about using the MetaData interface when exporting components, so using this, how can I get the desired result?

any right direction will be appreciated

+8
authentication c # mef user-controls
source share
4 answers

I did this using the metadata attribute for the module identifier and the rights table.

Make ImportMany on the interface, then filter it based on the metadata attribute using reflection, and compare with the permissions in the table.

This blog post describes all the MEFs 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 safety performance and profiles

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

+4
source share

The article here details the use of AOP to incorporate security concerns into the MEF. This may be one way to do this - I did not find anything in the MEF that would allow this function to be used elsewhere.

+2
source share

I think PRISM can do what you described. Take a look at this code draft article . You can create several module directories (according to user permissions) and dynamically load the catalog from XML, as described here :

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

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

Cinch helps with some of the hard work of MVVM, allowing you to use MEF through MeffedMVVM or Prism.

0
source share

All Articles