Como exportar e importar funções e executá-las com o MEF?
Estou criando um aplicativo que importa vários plugins. Eu preciso da capacidade de executar funções implementadas em cada um dos plugins. Por exemplo, eu preciso fazer algo assim.
/////////////////////////////////////////////////////////////////////////////////
MainApp:
[ImportMany(?)]
public IEnumerable<Lazy<?>> PluginFunctions1 { get; set; }
[ImportMany(?)]
public IEnumerable<Lazy<?>> PluginFunctions2 { get; set; }
foreach (f1 in PluginFunctions1)
{
f1(); // execute Function1 from each plugin
}
foreach (f2 in PluginFunctions2)
{
string result = f2(val); // execute Function2 from each plugin
}
/////////////////////////////////////////////////////////////////////////////////
Plugin:
[export(?)]
public void Function1()
{
}
[export(?)]
public string Function2(string value)
{
return result;
}
/////////////////////////////////////////////////////////////////////////////////
O problema é que não tenho certeza de como definir a importação e exportação e como executar exatamente a função.