Any suggestions how I could simplify this LINQ query?
from type in assembly.GetTypes()
where type.IsPublic && !type.IsSealed && type.IsClass
where (from method in type.GetMethods()
from typeEvent in type.GetEvents()
where method.Name.EndsWith("Async")
where typeEvent.Name.EndsWith("Completed")
let operationName = method.Name.Substring(0, method.Name.Length - "Async".Length)
where typeEvent.Name == operationName + "Completed"
select new { method, typeEvent }).Count() > 0
select type;
assembly
is of type System.Reflection.Assembly
.
If you need more information, just ask.
Count() > 0
withAny()
, which is simpler and also more efficient. – svick Jul 11 '12 at 18:38