C # Get the base class or interface class inherits all the methods of

 static  class ReflectionHelper 
    { 
        public  static the IEnumerable <T> CreateAllInstancesOf <T> () 
        { 
            return  typeof (ReflectionHelper) .Assembly.GetTypes () // Get the current library of all types 
                .Where (T => typeof (T) .IsAssignableFrom ( t)) // Get all types of indirect or direct succession t 
                .Where (t =>! && t.IsAbstract t.IsClass) // Get exclude non-abstract class interface inheritance 
                .Select (t => (T) Activator.CreateInstance (t)); // create instance, and returns the result (the project requirements, delete) 
        } 
    }

 

Guess you like

Origin www.cnblogs.com/Khan-Sadas/p/11345294.html