Using MEF, from inside the exporter, is it possible to find out who is importer using metadata ?
for example is this possible:
[Export("Config")]
String Config()
{
if (importer.metedata["name"] == "Circle")
return "R=10";
}
This way importer doesn’t need to pass something (his name, here) to tell the exporter who is he.
No, you can’t do that. It makes more sense to do this:
And the class which imports this method could look like this:
Note that directly importing and exporting methods (as
System.ActionorSystem.Func) is the quick and dirty way.It is better to declare a
IConfigurationProviderinterface instead and export that at the class level. This has two advantages:typeof(IConfigurationProvider).