Advertisement
Guest User

Untitled

a guest
May 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. public static IEnumerable<Type> GetTypesof<T>()
  2.     {
  3.         return from a in AppDomain.CurrentDomain.GetAssemblies()
  4.                from t in a.GetTypes()
  5.                where t.IsSubclassOf(typeof(T))
  6.                where !t.IsAbstract
  7.                where t.GetConstructor(Type.EmptyTypes) != null
  8.                select t;
  9.     }
  10.     public static IEnumerable<Type> GetTypesofInterface<T>()
  11.     {
  12.         return from a in AppDomain.CurrentDomain.GetAssemblies()
  13.                from t in a.GetTypes()
  14.                where !t.IsAbstract
  15.                where t.GetInterfaces().Contains(typeof(T))
  16.                where t.GetConstructor(Type.EmptyTypes) != null
  17.                select t;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement