using System; using System.Collections.Generic; using System.Linq; using System.Reflection; // The System.Reflection namespace is not used here because of the likelihood that another library will use identical functions. This can cause conflicts. namespace Elsa { public static class AssemblyExtensions { public static IEnumerable GetAllWithInterface(this Assembly assembly, Type @interface) => assembly.GetTypes().Where(t => t.IsClass && t.IsAbstract == false && t.GetInterfaces().Contains(@interface)); public static IEnumerable GetAllWithBaseClass(this Assembly assembly, Type baseClass) => assembly.GetTypes().Where(baseClass.IsAssignableFrom); //public static IEnumerable GetAllWithAttribute(this Assembly assembly, Type attribute) => assembly.GetTypes().Where(t => t.GetCustomAttributes(typeof(attribute), true).Length > 0); public static IEnumerable GetAllWithInterface(this Assembly assembly) => assembly.GetAllWithInterface(typeof(TType)); public static IEnumerable GetAllWithBaseClass(this Assembly assembly) => assembly.GetAllWithBaseClass(typeof(TType)); //public static IEnumerable GetAllWithAttribute(this Assembly assembly) => assembly.GetAllWithAttribute(typeof(TType)); } }