So i have a Type type and i need to find out, wheter there are types that derive from my type and what the types are which derive from my type and i cant just check all assemblies. Now the type i get is dynamic and i get a lot of those so i can't just check the assemblies everytime like this. I would use it, but beforehand i need to know wheter or not other classes derive from my type. Similar acticle, but he knew that he had a type that other classes derive from.
List<Type> list = new List<Type>();
foreach (Type type in Assembly.GetAssembly(myType).GetTypes().Where(i =>
i.IsClass && !i.IsAbstract && i.IsSubclassOf(myType)))
{
list.Add(type);
}
Aucun commentaire:
Enregistrer un commentaire