Hi
I have been looking at Steven Hollidges' MEF example here
Is there a way to call any method in the plugin dll that has been imported by passing the name of the method as string with parameters?
Here is the sample code showing the Calculate method being called:
// Production code would usually load the directory from configvar catalog = new DirectoryCatalog(@"..\..\..\Plugins");
var container = new CompositionContainer(catalog);
var pluginRepository = new PluginRepository()
{
CalculationServices = container.GetExportedValues<ICalculationService>()
};
foreach (var calculationService in pluginRepository.CalculationServices)
{
const int number1 = 10;
const int number2 = 20;
int result = calculationService.Calculate(number1, number2);
string output = string.Format("calculationService.Calculate({0},{1}) = {2}", number1, number2, result);
Console.WriteLine(output);
}