Morulus
2/1/2020 - 11:13 PM

Get derived class types

/* Not tested */
List<KeyValuePair<string, Type>> GetDerivedClassTypes<T>() {
      return Assembly.GetAssembly(typeof(T)).GetTypes()
      .Where(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(T)))
      .Select<Type, KeyValuePair<string, Type>>(type => new KeyValuePair<string, Type>(type.FullName.Substring(typeof(T).FullName.Length), (Type)type))
      .ToList();
  }