Skip to content

Instantly share code, notes, and snippets.

@bratsche
Created April 6, 2012 22:40
Show Gist options
  • Save bratsche/2323633 to your computer and use it in GitHub Desktop.
Save bratsche/2323633 to your computer and use it in GitHub Desktop.
Get implementations
List<T> GetInstances<T>()
{
return (from t in Assembly.GetExecutingAssembly().GetTypes()
where t.GetInterfaces().Contains(typeof (T)) && t.GetConstructor(Type.EmptyTypes) != null
select (T) Activator.CreateInstance(t)).ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment