I am working on a program that will communicate with various pieces of hardware. Because of the varied nature of the items it communicates and controls, I need to have a different "driver" for each different piece of hardware. This made me think that MEF would be a great way to make those drivers as plugins that can be added even after the product has been released.
I've looked at a lot of examples of how to use MEF, but the question that I haven't been able to find an answer to is how to populate a MEF plugin with external data (eg. from a database). All the examples I can find have the "data" hard-coded into the assembly, like the following example:
[Export( typeof( IRule ) )]
public class RuleInstance : IRule
{
public void DoIt() {}
public string Name
{
get { return "Rule Instance 3"; }
}
public string Version
{
get { return "1.1.0.0"; }
}
public string Description
{
get { return "Some Rule Instance"; }
}
}
What if I want Name, Version and Description to come from a database? How would I tell MEF where to get that information?
I may be missing something very obvious, but I don't know what it is.
Thanks! Joel