But you can write :
private static IEnumerable EnumerateInstances()
{
IEnumerable types = EnumerateTypes();
foreach(Type type in types)
{
var oResult = Test(type);
if (oResult != null)
{
yield return oResult;
}
}
}
private static IDocumentExtractor Test(Type type)
{
try
{
IDocumentExtractor extractor = Activator.CreateInstance(type) as IDocumentExtractor;
return extractor;
}
catch
{
return null;
//_log.WarnFormat("Type {0} couldn't be instanced.", type.Name);
}
}
It's just that Visual studio doesn't want to do this job, so you have to do it yourself (lazy compiler)