This project is read-only.

MEFProvider

MEFProvider is a static class that inits MEF for your application. Call the method .Init() and you are on the way. If you don't know what this functionality is all about you can go and read more at the MEF site.

What happens when you call init is that MEF goes and creates a catalog and a continer for extensions for your application. When you want to access the extensions you call a second method .SatisfyImportsOnce(oject). That's all!

Fortunately this is already done from the extended roles and pages in this namespace (Page, UserControl and WorkerRole). You as a developer need to do nothing appart from inheriting these classes in order to get this functionality.

You also have to have imports and exports in your code of course. IRoleManager is such an export. You can, and should, add your own exports. To access IRoleManager anywhere in your code all you have to do is:

foo()
{
    MEFProvider.SatisfyImportsOnce(this);
    Rolemanager.WriteToLog(EventLogName.Information, "I can now write to the log since the RoleManager has appeared for me through MEF.");
}

[Import(typeof(IRoleManager)]
IRoleManager RoleManager { get; set; }

Last edited Aug 24, 2009 at 12:55 PM by NoopMan, version 2

Comments

No comments yet.