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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With