When starting the application, you can register in the AssemblyLoad of your AppDomain:
AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(NewAssemblyLoaded);
and define NewAssemblyLoad to add IAnimal implementations to the list of types (e.g. animalTypes) that you support:
static void NewAssemblyLoaded(object sender, AssemblyLoadEventArgs args) { Assembly anAss = args.LoadedAssembly; foreach (Type t in Assembly.GetTypes()) { if (!t.IsInterface && typeof(IAnimal).IsAssignableFrom(t)) animalsList.Add(t); } }
source share