开发者

MEF Plugins with Security and Profiles Efficency

I have an application that has many modules/plugins. I am using MEF with a Directory plugin to import them. Each user has a list of available modules stored in a database and each user can have multiple profiles controlling which modules are visible.

There is an overview area showing inf开发者_高级运维ormation from all visible modules with an [ImportMany(typeof(IModule)] attribute.

What is a good way of handling this so that invisible or inaccessible modules are not created in memory.


Lazy loading them will ensure they are not initialised or loaded into memory. Then use metadata to find the module names and details.


Using [ImportMany(typeof(IModule)] will create an instance of each module - that's just the way MEF works. So one approach would be for the constructors of your Modules to do nothing, and then call a Load method on each Module that you actually want to use, in which it can do whatever work it needs to do.

Alternatively, create a new interface called IModuleInfo which just has the information necessary for your overview area.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜