答案 0 :(得分:1)
Because you are storing all the factories in a IEnumerable<ExportFactory<ITask,IMetaData>>
, there is no way you can determine the actual type of ITask without executing the factory's CreateExport() method (which I assume you don't want to do yet).
That being said: You are using the ExportFactory<,> with MetaData, so you could expand your IMetaData to contain a TaskType property. That would result in:
IEnumerable<ExportFactory<ITask,IMetaData>> myTasks = ...;
foreach (var task in myTasks)
{
Type taskType = task.Metadata.TaskType;
}