Reflection: How to locate/load a specific NameSpace inside an Assembly?
-
Hi, I'm trying to find all classes that implement a specific abstract base class inside an Assembly, so far I have got the following...
Assembly assm = Assembly.GetExecutingAssembly(); foreach (Type type in assm.GetTypes()) { if (type.IsSubclassOf(typeof(MyAbstractClass))) { Response.Write(type.ToString() + "<br />"); } }
...and this seems to work OK. However, my assembly is already fairly large and may grow, and as far as I can tell this code iterates through all types in the assembly, which I feel is inefficient. I know all my derived classes will sit inside the same namespace, so was wondering if there's a way to iterate through all types inside a particular namespace only, instead of the entire assembly? Cheers!Dominic Pettifer Blog: www.dominicpettifer.co.uk