Using reflection, this is how we get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations.
var type = typeof(IMyInterface);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
Basically, the least amount of iterations will always be:
loop assemblies
loop types
see if implemented.
References
https://stackoverflow.com/questions/26733/getting-all-types-that-implement-an-interface
Add to favorites