📅  最后修改于: 2022-03-11 14:48:52.728000             🧑  作者: Mango
public static class ReflectiveEnumerator
{
static ReflectiveEnumerator() { }
public static IEnumerable GetEnumerableOfType(params object[] constructorArgs) where T : class, IComparable
{
List objects = new List();
foreach (Type type in
Assembly.GetAssembly(typeof(T)).GetTypes()
.Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
{
objects.Add((T)Activator.CreateInstance(type, constructorArgs));
}
objects.Sort();
return objects;
}
}